Class: Nagare::Context
- Inherits:
-
Object
show all
- Defined in:
- lib/nagare.rb
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Context
Returns a new instance of Context.
132
133
134
|
# File 'lib/nagare.rb', line 132
def initialize(attributes = {})
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
148
149
150
151
152
|
# File 'lib/nagare.rb', line 148
def method_missing(method)
if @attributes.has_key?(method)
@attributes.fetch(method)
end
end
|
Instance Method Details
#[](key) ⇒ Object
140
141
142
|
# File 'lib/nagare.rb', line 140
def [](key)
@attributes[key]
end
|
#extend(attributes) ⇒ Object
136
137
138
|
# File 'lib/nagare.rb', line 136
def extend(attributes)
Context.new(@attributes.merge(attributes))
end
|
#respond_to?(key, private_methods = false) ⇒ Boolean
144
145
146
|
# File 'lib/nagare.rb', line 144
def respond_to?(key, private_methods = false)
@attributes.has_key?(key) || super
end
|