Class: Nagare::Context

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Context

Returns a new instance of Context.



118
119
120
# File 'lib/nagare.rb', line 118

def initialize(attributes = {})
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



134
135
136
137
138
# File 'lib/nagare.rb', line 134

def method_missing(method)
  if @attributes.has_key?(method)
    @attributes.fetch(method)
  end
end

Instance Method Details

#[](key) ⇒ Object



126
127
128
# File 'lib/nagare.rb', line 126

def [](key)
  @attributes[key]
end

#extend(attributes) ⇒ Object



122
123
124
# File 'lib/nagare.rb', line 122

def extend(attributes)
  Context.new(@attributes.merge(attributes))
end

#respond_to?(key, private_methods = false) ⇒ Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/nagare.rb', line 130

def respond_to?(key, private_methods = false)
  @attributes.has_key?(key) || super
end