Module: Challah::Rolls::Role::ClassMethods
- Defined in:
- lib/challah/rolls/role.rb
Instance Method Summary collapse
-
#[](name) ⇒ Role?
Quickly access a
Role
instance by the provided name. -
#admin ⇒ Role?
Shortcut for finding the Role named ‘Administrator’.
Instance Method Details
#[](name) ⇒ Role?
Quickly access a Role
instance by the provided name. If no Role
is found with that key, nil
is returned.
107 108 109 |
# File 'lib/challah/rolls/role.rb', line 107 def [](name) self.find_by_name(name.to_s.strip.downcase.gsub(' ', '_').titleize) end |
#admin ⇒ Role?
Shortcut for finding the Role named ‘Administrator’
117 118 119 |
# File 'lib/challah/rolls/role.rb', line 117 def admin @admin ||= self.find_by_name('Administrator') end |