Class: CustomStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/frontman/custom_struct.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *arguments, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/frontman/custom_struct.rb', line 15

def method_missing(method_id, *arguments, &block)
  if to_h.respond_to?(method_id)
    to_h.public_send(method_id, *arguments, &block)
  else
    super(method_id, *arguments)
  end
end

Instance Method Details

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/frontman/custom_struct.rb', line 11

def key?(key)
  to_h.key?(key)
end

#respond_to_missing?(method_id, *_arguments) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/frontman/custom_struct.rb', line 7

def respond_to_missing?(method_id, *_arguments)
  to_h.respond_to?(method_id) || super(method_id)
end