Sha256: d615ea0d8e037b60c1f946277940aad36486c3d2e1d470c93216d068eeccc66f
Contents?: true
Size: 897 Bytes
Versions: 40
Compression:
Stored size: 897 Bytes
Contents
#A normal hash that uses 'method_missing' to be able to call keys by using methods. It is heavily used by Knj::Objects and have some pre-defined methods because of it to optimize performance. #===Examples # hm = Knj::Hash_methods(:test => "Test") # print hm.test class Knj::Hash_methods < Hash #Spawns the object and takes a hash as argument. def initialize(hash = {}) self.update(hash) end #Returns the db-key. def db return self[:db] end #Returns the ob-key. def ob return self[:ob] end #Returns the args-key. def args return self[:args] end #Returns the data-key. def data return self[:data] end #Proxies methods into the hash as keys. def method_missing(method, *args) method = method.to_sym return self[method] if self.key?(method) raise "No such method '#{method}' on class '#{self.class.name}'" end end
Version data entries
40 entries across 40 versions & 1 rubygems