Class: Seedify::Base

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

Constant Summary

Constants included from Callbacks

Callbacks::TYPES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ParamReader

get_param_readers, inherited, param_reader

Methods included from Callbacks

get_callbacks, inherited, with_callbacks

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



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

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

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

Class Method Details

.call(overrides = {}) ⇒ Object



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

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

  Seedify::CallStack.call(seed)
end

.params(overrides) ⇒ Object



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

def self.params(overrides)
  stacked_params = ((last = Seedify::CallStack.last) ? last.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



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

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

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



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

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

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



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

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