Class: StrongHash::StrongHashFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/strong_hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ StrongHashFactory

Returns a new instance of StrongHashFactory.



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

def initialize(hash)
  @hash = ActiveSupport::HashWithIndifferentAccess.new(hash)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object

Raises:

  • (NoMethodError)


15
16
17
18
# File 'lib/strong_hash.rb', line 15

def method_missing(method_name)
  raise NoMethodError unless @hash[method_name]
  @hash[method_name]
end

Instance Method Details

#respond_to_missing?(method_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/strong_hash.rb', line 20

def respond_to_missing?(method_name, *args)
  super || @hash.respond_to?(method_name)
end