Class: Instructor::Defaults::Value
- Inherits:
-
Object
- Object
- Instructor::Defaults::Value
- Defined in:
- lib/instructor/concerns/defaults.rb
Instance Method Summary collapse
-
#initialize(static: nil, &block) ⇒ Value
constructor
A new instance of Value.
- #value ⇒ Object
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
#value ⇒ Object
31 32 33 |
# File 'lib/instructor/concerns/defaults.rb', line 31 def value (@value.respond_to?(:call) ? instance_eval(&@value) : @value).dup end |