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.



32
33
34
# File 'lib/flow/state/options.rb', line 32

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

Instance Method Details

#default_valueObject



36
37
38
39
40
# File 'lib/flow/state/options.rb', line 36

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

  @default_value
end