Class: Wikidata::HashedObject
- Inherits:
-
Object
- Object
- Wikidata::HashedObject
- Defined in:
- lib/wikidata/hashed_object.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data_hash ⇒ Object
readonly
Returns the value of attribute data_hash.
Instance Method Summary collapse
-
#initialize(data_hash) ⇒ HashedObject
constructor
A new instance of HashedObject.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(data_hash) ⇒ HashedObject
Returns a new instance of HashedObject.
6 7 8 |
# File 'lib/wikidata/hashed_object.rb', line 6 def initialize(data_hash) @data_hash = Hashie::Mash.new(data_hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/wikidata/hashed_object.rb', line 10 def method_missing(meth, *args, &block) if data_hash.has_key?(meth.to_s) data_hash[meth.to_s] else super end end |
Instance Attribute Details
#data_hash ⇒ Object (readonly)
Returns the value of attribute data_hash.
4 5 6 |
# File 'lib/wikidata/hashed_object.rb', line 4 def data_hash @data_hash end |