Created
January 19, 2012 21:54
-
-
Save simeonwillbanks/1643099 to your computer and use it in GitHub Desktop.
#Rails Params Hash Encapsulated #ruby #method_missing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EncapsulatedHash | |
| def initialize(h) | |
| @encapsulated = ActiveSupport::HashWithIndifferentAccess.new | |
| h.each_pair {|key, value| @encapsulated[key] = value } | |
| end | |
| def method_missing(m, *args, &block) | |
| if @encapsulated.respond_to? m | |
| @encapsulated.send(m, *args, &block) | |
| else | |
| super | |
| end | |
| end | |
| def respond_to?(m, include_private = false) | |
| if @encapsulated.respond_to? m | |
| return true | |
| end | |
| super | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment