Class: Seedify::Base

Inherits:
Object
  • Object
show all
Extended by:
ParamReader
Defined in:
lib/seedify/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ParamReader

get_param_readers, inherited, param_reader

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



25
26
27
28
# File 'lib/seedify/base.rb', line 25

def initialize(params)
  @params = params
  @logger = Seedify::Logger.new(self)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'lib/seedify/base.rb', line 5

def params
  @params
end

Class Method Details

.call(overrides = {}) ⇒ Object



10
11
12
13
14
# File 'lib/seedify/base.rb', line 10

def self.call(overrides = {})
  seed = self.new(params(overrides))

  Seedify::CallStack.call(seed)
end

.params(overrides) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/seedify/base.rb', line 16

def self.params(overrides)
  stacked_params = (Seedify::CallStack.last.try(:params) || {}).merge(overrides)
  defined_params = get_param_readers.map do |param_name, options|
    [param_name, Seedify::ParamValue.get(param_name, options)]
  end.to_h

  defined_params.merge(stacked_params)
end

Instance Method Details

#log(message, &block) ⇒ Object



30
31
32
# File 'lib/seedify/base.rb', line 30

def log(message, &block)
  @logger.line(message, &block)
end

#log_each(array, message, &block) ⇒ Object



34
35
36
# File 'lib/seedify/base.rb', line 34

def log_each(array, message, &block)
  @logger.each(array, message, &block)
end

#log_times(count, message, &block) ⇒ Object



38
39
40
# File 'lib/seedify/base.rb', line 38

def log_times(count, message, &block)
  @logger.times(count, message, &block)
end