Skip to content

Instantly share code, notes, and snippets.

@simeonwillbanks
Created January 19, 2012 21:54
Show Gist options
  • Select an option

  • Save simeonwillbanks/1643099 to your computer and use it in GitHub Desktop.

Select an option

Save simeonwillbanks/1643099 to your computer and use it in GitHub Desktop.
#Rails Params Hash Encapsulated #ruby #method_missing
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