Class: State::Options::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/flow/state/options.rb

Instance Method Summary collapse

Constructor Details

#initialize(default:, &block) ⇒ Option

Returns a new instance of Option.



34
35
36
# File 'lib/flow/state/options.rb', line 34

def initialize(default:, &block)
  @default_value = (default.nil? && block_given?) ? block : default
end

Instance Method Details

#default_valueObject



38
39
40
41
42
# File 'lib/flow/state/options.rb', line 38

def default_value
  return instance_eval(&@default_value) if @default_value.respond_to?(:call)

  @default_value
end