Class: Instructor::Defaults::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/instructor/concerns/defaults.rb

Instance Method Summary collapse

Constructor Details

#initialize(static: nil, &block) ⇒ Value

Returns a new instance of Value.



27
28
29
# File 'lib/instructor/concerns/defaults.rb', line 27

def initialize(static: nil, &block)
  @value = (static.nil? && block_given?) ? block : static
end

Instance Method Details

#valueObject



31
32
33
# File 'lib/instructor/concerns/defaults.rb', line 31

def value
  (@value.respond_to?(:call) ? instance_eval(&@value) : @value).dup
end