Class: Mayu::State::Loader::ReducerBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
ReducerDSL
Defined in:
lib/mayu/state/loader.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, data) ⇒ ReducerBuilder

Returns a new instance of ReducerBuilder.



139
140
141
142
# File 'lib/mayu/state/loader.rb', line 139

def initialize(prefix, data)
  @prefix = prefix
  @data = data
end

Class Method Details

.build(source, path) ⇒ Object



132
133
134
135
136
# File 'lib/mayu/state/loader.rb', line 132

def self.build(source, path)
  { initial_state: nil, reducers: [], actions: [] }.tap do
    new(File.basename(path, ".*"), _1).instance_eval(source, path, 0)
  end
end

Instance Method Details

#actions(&block) ⇒ Object



177
178
179
# File 'lib/mayu/state/loader.rb', line 177

def actions(&block)
  @data[:actions] = Actions::ActionModule.build(&block)
end

#fetch(url, **options) ⇒ Object



150
151
# File 'lib/mayu/state/loader.rb', line 150

def fetch(url, **options)
end

#initial_state(**kwargs) ⇒ Object



145
146
147
# File 'lib/mayu/state/loader.rb', line 145

def initial_state(**kwargs)
  @data[:initial_state] = kwargs
end

#reducer(action, &reducer) ⇒ Object



186
187
188
# File 'lib/mayu/state/loader.rb', line 186

def reducer(action, &reducer)
  @data[:reducers].push([action, reducer])
end

#selectors(&block) ⇒ Object



165
166
167
# File 'lib/mayu/state/loader.rb', line 165

def selectors(&block)
  @data[:selectors] = Selector::SelectorModule.build(&block)
end