Module: DarDaDa::ActiveRecordExtension::InstanceMethods
- Defined in:
- lib/dar_da_da/active_record_extension.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
41 42 43 |
# File 'lib/dar_da_da/active_record_extension.rb', line 41 def self.included(base) base.send :before_save, :set_role_to_default_value end |
Instance Method Details
#allowed_to?(name) ⇒ Boolean
53 54 55 56 |
# File 'lib/dar_da_da/active_record_extension.rb', line 53 def allowed_to?(name) rights = self.class.dar_dar_da[role] !!rights && !name.blank? && rights.include?(name.to_sym) end |
#role ⇒ Object
45 46 47 |
# File 'lib/dar_da_da/active_record_extension.rb', line 45 def role role_symbol.to_s end |
#role=(new_role) ⇒ Object
49 50 51 |
# File 'lib/dar_da_da/active_record_extension.rb', line 49 def role=(new_role) write_role_attribute(new_role) if self.class.dar_dar_da[new_role] end |