Skip to content

Instantly share code, notes, and snippets.

@vrinek
Created October 1, 2012 10:49
Show Gist options
  • Select an option

  • Save vrinek/3810911 to your computer and use it in GitHub Desktop.

Select an option

Save vrinek/3810911 to your computer and use it in GitHub Desktop.
if @user.try(:can_edit_post?)
# do something
end
def method_missing(method_name, *args, &block)
if method_name =~ /^can_.+\?$/
action = method_name[/^can_(.+)\?$/, 1].to_sym
@can_do.include?(action)
else
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment