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



43
44
45
# File 'lib/dar_da_da/active_record_extension.rb', line 43

def self.included(base)
  base.send :before_save, :set_role_to_default_value
end

Instance Method Details

#allowed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/dar_da_da/active_record_extension.rb', line 55

def allowed_to?(name)
  rights = self.class.dar_dar_da[role]
  !!rights && !name.blank? && rights.include?(name.to_sym)
end

#roleObject



47
48
49
# File 'lib/dar_da_da/active_record_extension.rb', line 47

def role
  role_symbol.to_s
end

#role=(new_role) ⇒ Object



51
52
53
# File 'lib/dar_da_da/active_record_extension.rb', line 51

def role=(new_role)
  write_role_attribute(new_role) if self.class.dar_dar_da[new_role]
end