Module: SystemFixtures::Roles
- Included in:
- Role
- Defined in:
- lib/generators/permissify/role/template/roles.rb
Constant Summary collapse
- SEEDED_ORDERED_ROLES =
['super user', 'system admin', 'dealer admin', 'corporation admin', 'brand admin', 'merchant admin']
- SEED_SPECIFICATIONS =
SEEDED_ORDERED_ROLES = [‘super user’, ‘system admin’, ‘operations agent’, ‘call center agent’]
(1..SEEDED_ORDERED_ROLES.length).zip(SEEDED_ORDERED_ROLES)
Instance Method Summary collapse
- #brand_admin_permissions ⇒ Object
- #corporation_admin_permissions ⇒ Object
- #create_brand_admin ⇒ Object
- #create_corporation_admin ⇒ Object
- #create_dealer_admin ⇒ Object
- #create_merchant_admin ⇒ Object
- #create_super_user ⇒ Object
- #create_system_admin ⇒ Object
- #create_with(id, domain_type) ⇒ Object
- #dealer_admin_permissions ⇒ Object
- #merchant_admin_permissions ⇒ Object
- #msa_permissions(exclude_abilities) ⇒ Object
- #seed ⇒ Object
- #seeded?(role) ⇒ Boolean
- #super_user_permissions ⇒ Object
- #system_admin_permissions ⇒ Object
Instance Method Details
#brand_admin_permissions ⇒ Object
45 46 47 48 |
# File 'lib/generators/permissify/role/template/roles.rb', line 45 def %w(corporation brands_create brands_delete) Ability. %w(tabs_corporations brand_products_update merchant_products_update) end |
#corporation_admin_permissions ⇒ Object
42 43 44 |
# File 'lib/generators/permissify/role/template/roles.rb', line 42 def %w(corporations_create corporations_delete) end |
#create_brand_admin ⇒ Object
21 |
# File 'lib/generators/permissify/role/template/roles.rb', line 21 def create_brand_admin; create_with(5, 'Brand') ; end |
#create_corporation_admin ⇒ Object
20 |
# File 'lib/generators/permissify/role/template/roles.rb', line 20 def create_corporation_admin; create_with(4, 'Corporation') ; end |
#create_dealer_admin ⇒ Object
19 |
# File 'lib/generators/permissify/role/template/roles.rb', line 19 def create_dealer_admin; create_with(3, 'Dealer') ; end |
#create_merchant_admin ⇒ Object
22 |
# File 'lib/generators/permissify/role/template/roles.rb', line 22 def create_merchant_admin; create_with(6, 'Merchant') ; end |
#create_super_user ⇒ Object
17 |
# File 'lib/generators/permissify/role/template/roles.rb', line 17 def create_super_user; create_with(1, 'Admin') ; end |
#create_system_admin ⇒ Object
18 |
# File 'lib/generators/permissify/role/template/roles.rb', line 18 def create_system_admin; create_with(2, 'Admin') ; end |
#create_with(id, domain_type) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/generators/permissify/role/template/roles.rb', line 24 def create_with(id, domain_type) role = create_with_id(:role, id, SEED_SPECIFICATIONS.assoc(id)[1]) role.domain_type = domain_type role.save role end |
#dealer_admin_permissions ⇒ Object
37 38 39 40 |
# File 'lib/generators/permissify/role/template/roles.rb', line 37 def Ability.( [], %w(roles products admin)) Ability. %w(tabs_admin dealers_create dealers_delete dealer_users_create dealer_users_delete) end |
#merchant_admin_permissions ⇒ Object
49 50 51 52 |
# File 'lib/generators/permissify/role/template/roles.rb', line 49 def %w(corporation brand) Ability. %w(tabs_brands tabs_corporations merchant_products_update) end |
#msa_permissions(exclude_abilities) ⇒ Object
53 54 55 56 57 |
# File 'lib/generators/permissify/role/template/roles.rb', line 53 def (exclude_abilities) no_abilities = exclude_abilities + %w(admin roles products dealer) Ability.([], no_abilities) Ability. %w(tabs_admin tabs_dealers) end |
#seed ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/generators/permissify/role/template/roles.rb', line 7 def seed create_seeds SEED_SPECIFICATIONS Role.find(1).manage_ids = [2,3,4,5,6] Role.find(2).manage_ids = [2,3,4,5,6] Role.find(3).manage_ids = [3,4,5,6] Role.find(4).manage_ids = [4,5,6] Role.find(5).manage_ids = [6] Role.find(6).manage_ids = [6] end |
#seeded?(role) ⇒ Boolean
6 |
# File 'lib/generators/permissify/role/template/roles.rb', line 6 def seeded?(role); role.id <= SEEDED_ORDERED_ROLES.length; end |
#super_user_permissions ⇒ Object
31 32 33 |
# File 'lib/generators/permissify/role/template/roles.rb', line 31 def Ability. end |
#system_admin_permissions ⇒ Object
34 35 36 |
# File 'lib/generators/permissify/role/template/roles.rb', line 34 def Ability. %w(roles products) end |