Class: RecursiveClosedStruct
- Inherits:
-
Object
- Object
- RecursiveClosedStruct
- Defined in:
- lib/prawn_cocktail/utils/recursive_closed_struct.rb
Instance Method Summary collapse
- #has_key?(key) ⇒ Boolean
-
#initialize(hash) ⇒ RecursiveClosedStruct
constructor
A new instance of RecursiveClosedStruct.
- #method_missing(name) ⇒ Object
Constructor Details
#initialize(hash) ⇒ RecursiveClosedStruct
Returns a new instance of RecursiveClosedStruct.
2 3 4 |
# File 'lib/prawn_cocktail/utils/recursive_closed_struct.rb', line 2 def initialize(hash) @hash = hash end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/prawn_cocktail/utils/recursive_closed_struct.rb', line 10 def method_missing(name, *) value = fetch(name) if value.is_a?(Hash) self.class.new(value) else value end end |
Instance Method Details
#has_key?(key) ⇒ Boolean
6 7 8 |
# File 'lib/prawn_cocktail/utils/recursive_closed_struct.rb', line 6 def has_key?(key) @hash.has_key? key end |