Class: Role
Constant Summary
collapse
- DOMAIN_TYPES =
%w(Admin Dealer Corporation Brand Merchant)
- PERMISSIFIED_ABILITY_APPLICABILITY =
'Role'
Instance Attribute Summary
#from, #from_permissions_model
Class Method Summary
collapse
Instance Method Summary
collapse
create_seeds, create_with_id, force_seed_id, locate, underscored_name_symbol
#allows?, #establish_from_permissions_model, #initialize_permissions, #remove_permissions, #underscored_name_symbol, #update_permissions
Class Method Details
.force_seed_id(table, permissions_model, id) ⇒ Object
21
22
23
24
|
# File 'lib/generators/permissify/role/template/role.rb', line 21
def force_seed_id(table, permissions_model, id)
ActiveRecord::Base.connection.execute "UPDATE #{table}s SET id=#{id} WHERE id=#{permissions_model.id};"
end
|
Instance Method Details
#copy_non_permissions_values ⇒ Object
36
37
38
39
40
|
# File 'lib/generators/permissify/role/template/role.rb', line 36
def copy_non_permissions_values
self.domain_type = self.from_permissions_model.domain_type
self.managers = self.from_permissions_model.managers
self.manages = self.from_permissions_model.manages
end
|
#default_non_permissions_values ⇒ Object
31
32
33
34
|
# File 'lib/generators/permissify/role/template/role.rb', line 31
def default_non_permissions_values
self.domain_type = DOMAIN_TYPES.last if self.domain_type.blank?
self.name = self.name.gsub("'","")
end
|
#initialize_non_permission_values ⇒ Object
27
28
29
|
# File 'lib/generators/permissify/role/template/role.rb', line 27
def initialize_non_permission_values
establish_from_permissions_model.nil? ? default_non_permissions_values : copy_non_permissions_values
end
|
#remove(permissions_list) ⇒ Object
42
|
# File 'lib/generators/permissify/role/template/role.rb', line 42
def remove(permissions_list); permissions_list.each{|permission| self.permissions.delete(permission)}; save; end
|