Class: Compass::LazyAttribute::LazyValue

Inherits:
Object
  • Object
show all
Defined in:
lib/compass/lazy_attribute.rb

Overview

A lazy evaluated value, evaluated in the given context when required.

Instance Method Summary collapse

Constructor Details

#initialize(ctx, value) ⇒ LazyValue

Returns a new instance of LazyValue.



10
11
12
13
# File 'lib/compass/lazy_attribute.rb', line 10

def initialize(ctx, value)
  @ctx = ctx
  @value = value
end

Instance Method Details

#getObject



15
16
17
18
19
20
21
# File 'lib/compass/lazy_attribute.rb', line 15

def get
  case @value
  when Symbol then @ctx.send(@value)
  when Proc then @ctx.instance_exec(&@value)
  else @value
  end
end