Class: OpenHash
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(hash = {}) ⇒ OpenHash
constructor
A new instance of OpenHash.
-
#method_missing(name, *args) ⇒ Object
Allow hash properties to be referenced by dot notation.
Methods inherited from Hash
#to_openhash, #to_post_fields, #to_querystring
Constructor Details
#initialize(hash = {}) ⇒ OpenHash
Returns a new instance of OpenHash.
4 5 6 7 |
# File 'lib/wikibot/vendor/openhash.rb', line 4 def initialize(hash = {}) super() update(hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Allow hash properties to be referenced by dot notation
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wikibot/vendor/openhash.rb', line 15 def method_missing(name, *args) name = name.to_s k = name.sub(/[?!=]$/, '') if name =~ /=$/ && !args.empty? self[k] = args.first elsif self.include? k self[k] elsif self.include? k.to_sym self[k.to_sym] end end |