Class: Wikidata::HashedObject

Inherits:
Object
  • Object
show all
Defined in:
lib/wikidata/hashed_object.rb

Direct Known Subclasses

DataValues::Value, Entity, IdentityMap, Snak, Statement

Instance Attribute Summary collapse

Instance Method Summary collapse

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_hashObject (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