Class: RecursiveClosedStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn_cocktail/utils/recursive_closed_struct.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


6
7
8
# File 'lib/prawn_cocktail/utils/recursive_closed_struct.rb', line 6

def has_key?(key)
  @hash.has_key? key
end