Skip to content

Instantly share code, notes, and snippets.

@szimek
Created May 21, 2010 19:08
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 szimek/1526bf48b78eee94e6f0 to your computer and use it in GitHub Desktop.
Save szimek/1526bf48b78eee94e6f0 to your computer and use it in GitHub Desktop.
def define_hash_access(route, name, kind, options)
selector = hash_access_name(name, kind)
# We use module_eval to avoid leaks
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
def #{selector}(options = nil) # def hash_for_users_url(options = nil)
options ? #{options.inspect}.merge(options) : #{options.inspect} # options ? {:only_path=>false}.merge(options) : {:only_path=>false}
end # end
protected :#{selector} # protected :hash_for_users_url
END_EVAL
helpers << selector
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment