Class: Substance::Objects::Defaults::Value

Inherits:
Object
  • Object
show all
Includes:
Tablesalt::Isolation
Defined in:
lib/substance/objects/defaults.rb

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Value.



32
33
34
# File 'lib/substance/objects/defaults.rb', line 32

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

Instance Method Details

#valueObject



36
37
38
# File 'lib/substance/objects/defaults.rb', line 36

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