Class: Lite::Component::Locals

Inherits:
Object
  • Object
show all
Defined in:
lib/lite/component/locals.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locals) ⇒ Locals

Returns a new instance of Locals.



12
13
14
# File 'lib/lite/component/locals.rb', line 12

def initialize(locals)
  @locals = (locals || {}).symbolize_keys
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object (private)



18
19
20
21
22
23
24
# File 'lib/lite/component/locals.rb', line 18

def method_missing(method_name, *arguments, &block)
  if locals.key?(method_name)
    locals[method_name]
  else
    super
  end
end

Instance Attribute Details

#localsObject (readonly) Also known as: to_hash, to_h

Returns the value of attribute locals.



7
8
9
# File 'lib/lite/component/locals.rb', line 7

def locals
  @locals
end