Class: StrongHash::StrongHashFactory
- Inherits:
-
Object
- Object
- StrongHash::StrongHashFactory
- Defined in:
- lib/strong_hash.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ StrongHashFactory
constructor
A new instance of StrongHashFactory.
- #method_missing(method_name) ⇒ Object
- #respond_to_missing?(method_name, *args) ⇒ Boolean
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
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
20 21 22 |
# File 'lib/strong_hash.rb', line 20 def respond_to_missing?(method_name, *args) super || @hash.respond_to?(method_name) end |