Skip to content

Instantly share code, notes, and snippets.

@coop
Created October 11, 2011 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coop/1277785 to your computer and use it in GitHub Desktop.
Save coop/1277785 to your computer and use it in GitHub Desktop.
class FeaturesHash < HashWithIndifferentAccess
def with_features features
current = dup
replace features
yield
ensure
replace current
end
def method_missing method, *args, &block
method.to_s =~ /(.+)\??$/
fetch($1) { super }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment