Class: InheritableAccessors::InheritableOptionAccessor::LetOption

Inherits:
Object
  • Object
show all
Defined in:
lib/inheritable_accessors/inheritable_option_accessor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ LetOption

Returns a new instance of LetOption.



35
36
37
38
# File 'lib/inheritable_accessors/inheritable_option_accessor.rb', line 35

def initialize(block)
  @block = block
  @memoized = {}
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



33
34
35
# File 'lib/inheritable_accessors/inheritable_option_accessor.rb', line 33

def block
  @block
end

Instance Method Details

#with_context(context) ⇒ Object



40
41
42
43
44
# File 'lib/inheritable_accessors/inheritable_option_accessor.rb', line 40

def with_context(context)
  @memoized[context] ||= begin
    context.instance_exec(&block)
  end
end