From 2a3d2ec14995ff84560ea0129844a74cefc4eab4 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Sat, 12 Aug 2017 02:32:29 +0000 Subject: [PATCH] Move Obredux::Thunk to separate file --- lib/actions.rb | 2 -- lib/main.rb | 3 +++ lib/obredux.rb | 13 ------------- lib/obredux/thunk.rb | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 lib/obredux/thunk.rb diff --git a/lib/actions.rb b/lib/actions.rb index b8ceef2..519f376 100644 --- a/lib/actions.rb +++ b/lib/actions.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'obredux' - require 'actions/load_friends' require 'actions/add_friend' require 'actions/add_friend_message' diff --git a/lib/main.rb b/lib/main.rb index 1b325b9..a613433 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -4,6 +4,9 @@ require 'tox' require 'singleton' +require 'obredux' +require 'obredux/thunk' + require 'helpers' require 'actions' require 'reducer' diff --git a/lib/obredux.rb b/lib/obredux.rb index b1bb429..01f483a 100644 --- a/lib/obredux.rb +++ b/lib/obredux.rb @@ -13,19 +13,6 @@ module Obredux end end - class Thunk < Middleware - def call(store, action) - return action unless action.is_a? Action - action.call store.public_method :dispatch - end - - class Action < Action - def call(_dispatch) - raise NotImplementedError, "#{self.class}#call" - end - end - end - class Store attr_reader :reducer_klass, :state, :middleware diff --git a/lib/obredux/thunk.rb b/lib/obredux/thunk.rb new file mode 100644 index 0000000..2fb0f61 --- /dev/null +++ b/lib/obredux/thunk.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'obredux' + +module Obredux + class Thunk < Middleware + def call(store, action) + return action unless action.is_a? Action + action.call store.public_method :dispatch + end + + class Action < Action + def call(_dispatch) + raise NotImplementedError, "#{self.class}#call" + end + end + end +end