Module: Challah::Rolls::Permission::ClassMethods

Defined in:
lib/challah/rolls/permission.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Permission?

Quickly access a Permission instance by the provided key. If no Permission is found with that key, nil is returned.

Examples:

Permission[:admin] # => Permission.find_by_key('admin')
Permission['manage_users'] # => Permission.find_by_key('manage_users')
Permission[:does_not_exist] # => nil

Parameters:

  • key (Symbol, String)

    A permission key to locate.

Returns:



90
91
92
# File 'lib/challah/rolls/permission.rb', line 90

def [](key)
  self.find_by_key(key.to_s.strip.downcase.gsub(' ', '_'))
end