Class: Greenenvy::OpenStructLike

Inherits:
BasicObject
Defined in:
lib/greenenvy/open_struct_like.rb

Defined Under Namespace

Classes: MethodMissingHandler

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ OpenStructLike

Returns a new instance of OpenStructLike.



3
4
5
6
# File 'lib/greenenvy/open_struct_like.rb', line 3

def initialize(hash)
  @hash = hash
  @method_missing_handler = MethodMissingHandler.new(hash)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *_) ⇒ Object



8
9
10
# File 'lib/greenenvy/open_struct_like.rb', line 8

def method_missing(name, *_)
  @method_missing_handler.call(name)
end

Instance Method Details

#inspectObject



12
13
14
# File 'lib/greenenvy/open_struct_like.rb', line 12

def inspect
  @hash.inspect
end