Class: Tumblargh::Resource::Base
- Inherits:
-
Object
- Object
- Tumblargh::Resource::Base
- Defined in:
- lib/tumblargh/resource/base.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#context ⇒ Object
Needed by renderer for context propagation.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Base
constructor
A new instance of Base.
- #method_missing(method_symbol, *arguments) ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/tumblargh/resource/base.rb', line 9 def initialize(attrs={}) self.attributes = attrs end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_symbol, *arguments) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tumblargh/resource/base.rb', line 19 def method_missing(method_symbol, *arguments) method_name = method_symbol.to_s if method_name =~ /(=|\?)$/ case $1 when "=" attributes[$`] = arguments.first when "?" attributes[$`] end else return attributes[method_name] if attributes.include?(method_name) # propagating renderer context return context.send(method_symbol, *arguments) unless context.nil? end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
13 14 15 |
# File 'lib/tumblargh/resource/base.rb', line 13 def attributes @attributes end |
#context ⇒ Object
Needed by renderer for context propagation
7 8 9 |
# File 'lib/tumblargh/resource/base.rb', line 7 def context @context end |