Class: Qismo::ObjectifiedHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/qismo/objectified_hash.rb

Overview

Objectified hash interface for accesing hash using dot notation

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

method missing patch



6
7
8
9
10
# File 'lib/qismo/objectified_hash.rb', line 6

def method_missing(method, *args, &block)
  return super unless respond_to?(method)

  fetch(method.to_s)
end

Instance Method Details

#respond_to?(method_name, include_private = false) ⇒ Boolean

respond to patch

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/qismo/objectified_hash.rb', line 13

def respond_to?(method_name, include_private = false)
  fetch(method_name.to_s)

  true
rescue KeyError
  super(method_name, include_private)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

respond to missing patch

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/qismo/objectified_hash.rb', line 22

def respond_to_missing?(method_name, include_private = false)
  fetch(method_name.to_s)

  true
rescue KeyError
  super(method_name, include_private)
end