Class: RackMailbox
- Inherits:
-
Object
- Object
- RackMailbox
- Defined in:
- lib/racked.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ RackMailbox
constructor
A new instance of RackMailbox.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ RackMailbox
Returns a new instance of RackMailbox.
14 15 16 17 |
# File 'lib/racked.rb', line 14 def initialize(attributes) @attributes = attributes #JSON.parse(json) puts @attributes.keys.inspect end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/racked.rb', line 19 def method_missing(method, *args) #x = name.to_s.camelize(:lower) x = method.to_s #return @attributes[access_key] if(@attributes.keys.include?(access_key)) if(@attributes.keys.include?(x)) @attributes[x] else super end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
12 13 14 |
# File 'lib/racked.rb', line 12 def attributes @attributes end |