Module: GlobalRoles::Methods
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/global_roles/methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #global_role ⇒ Object
- #global_role=(name) ⇒ Object
- #global_role_id ⇒ Object
- #global_role_id=(id) ⇒ Object
- #reload_global_role ⇒ Object
Instance Method Details
#global_role ⇒ Object
5 6 7 |
# File 'lib/global_roles/methods.rb', line 5 def global_role @global_role ||= self.class::ROLES[self.global_role_id] end |
#global_role=(name) ⇒ Object
17 18 19 20 |
# File 'lib/global_roles/methods.rb', line 17 def global_role=(name) @global_role = nil write_attribute(:global_role, self.class::global_role_id_for(name)) end |
#global_role_id ⇒ Object
9 10 11 |
# File 'lib/global_roles/methods.rb', line 9 def global_role_id self.read_attribute :global_role end |
#global_role_id=(id) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/global_roles/methods.rb', line 22 def global_role_id=(id) unless id.is_a? Fixnum raise ArgumentError, "Expected a Fixnum, but got \#{id.inspect}" end id = self.class::global_role_id_for(id) @global_role = nil write_attribute(:global_role, id) end |
#reload_global_role ⇒ Object
13 14 15 |
# File 'lib/global_roles/methods.rb', line 13 def reload_global_role @global_role = nil end |