Class: Portrayal::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/portrayal/default.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Default

Returns a new instance of Default.



5
6
7
8
# File 'lib/portrayal/default.rb', line 5

def initialize(value)
  @value = value
  @callable = value.is_a?(Proc) && !value.lambda?
end

Instance Method Details

#call(obj) ⇒ Object



10
# File 'lib/portrayal/default.rb', line 10

def call(obj); @callable ? obj.instance_exec(&value) : value end

#initialize_dup(src) ⇒ Object



11
# File 'lib/portrayal/default.rb', line 11

def initialize_dup(src); @value = src.value.dup; super end