Module: SystemFixtures::Products

Included in:
Product
Defined in:
lib/generators/permissify/product/template/products.rb

Constant Summary collapse

SEED_SPECIFICATIONS =
[
  [1,   'Basic Service'],
  [2,   'Online Ordering'],
  [3,   'Loyalty'],
  [4,   'Webpage Builder'],
  [5,   'eGift'],
  [6,   'Guest Management'],
  [7,   'Marketing Engine'],
  [8,   'Social Media 1'],
  [9,   'Social Media 2'],
  [10,  'Social Media 3'],
  [11,  'Social Marketing Engine'],
]

Instance Method Summary collapse

Instance Method Details

#basic_service_permissionsObject



32
33
34
# File 'lib/generators/permissify/product/template/products.rb', line 32

def basic_service_permissions
  ph :basic_service_on
end

#create_basic_serviceObject



19
# File 'lib/generators/permissify/product/template/products.rb', line 19

def create_basic_service;           create_with 1; end

#create_egiftObject



23
# File 'lib/generators/permissify/product/template/products.rb', line 23

def create_egift;                   create_with 5; end

#create_guest_managementObject



24
# File 'lib/generators/permissify/product/template/products.rb', line 24

def create_guest_management;        create_with 6; end

#create_loyaltyObject



21
# File 'lib/generators/permissify/product/template/products.rb', line 21

def create_loyalty;                 create_with 3; end

#create_marketing_engineObject



25
# File 'lib/generators/permissify/product/template/products.rb', line 25

def create_marketing_engine;        create_with 7; end

#create_online_orderingObject



20
# File 'lib/generators/permissify/product/template/products.rb', line 20

def create_online_ordering;         create_with 2; end

#create_social_marketing_engineObject



29
# File 'lib/generators/permissify/product/template/products.rb', line 29

def create_social_marketing_engine; create_with 11; end

#create_social_media_1Object



26
# File 'lib/generators/permissify/product/template/products.rb', line 26

def create_social_media_1;          create_with 8; end

#create_social_media_2Object



27
# File 'lib/generators/permissify/product/template/products.rb', line 27

def create_social_media_2;          create_with 9; end

#create_social_media_3Object



28
# File 'lib/generators/permissify/product/template/products.rb', line 28

def create_social_media_3;          create_with 10; end

#create_webpage_builderObject



22
# File 'lib/generators/permissify/product/template/products.rb', line 22

def create_webpage_builder;         create_with 4; end

#create_with(id) ⇒ Object



30
# File 'lib/generators/permissify/product/template/products.rb', line 30

def create_with(id); create_with_id(:product, id, SEED_SPECIFICATIONS.assoc(id)[1]); end

#egift_permissionsObject



38
# File 'lib/generators/permissify/product/template/products.rb', line 38

def egift_permissions; ph :egift_on; end

#guest_management_permissionsObject



39
# File 'lib/generators/permissify/product/template/products.rb', line 39

def guest_management_permissions; ph :guest_management_on; end

#loyalty_permissionsObject



36
# File 'lib/generators/permissify/product/template/products.rb', line 36

def loyalty_permissions; ph :loyalty_on; end

#marketing_engine_permissionsObject



40
# File 'lib/generators/permissify/product/template/products.rb', line 40

def marketing_engine_permissions; ph :marketing_engine_on; end

#online_ordering_permissionsObject



35
# File 'lib/generators/permissify/product/template/products.rb', line 35

def online_ordering_permissions; ph :online_ordering_on; end

#ph(permissions) ⇒ Object



65
66
67
68
69
70
# File 'lib/generators/permissify/product/template/products.rb', line 65

def ph(permissions)
  permissions_hash = {}
  permissions = [permissions] unless permissions.kind_of?(Array)
  permissions.each{|p| permissions_hash[p.to_s] = {"0"=>"1"}}
  permissions_hash
end

#seedObject



17
# File 'lib/generators/permissify/product/template/products.rb', line 17

def seed; create_seeds SEED_SPECIFICATIONS; end

#seeded?(product) ⇒ Boolean

Returns:

  • (Boolean)


16
# File 'lib/generators/permissify/product/template/products.rb', line 16

def seeded?(product); product.id <= SEED_SPECIFICATIONS.count; end

#social_marketing_engine_permissionsObject



58
59
60
61
62
63
# File 'lib/generators/permissify/product/template/products.rb', line 58

def social_marketing_engine_permissions
  permissions = social_media_3_permissions
  permissions['marketing_engine_on'] = {'0' => '1'}
  permissions['social_media_repeat'] = {'0' => '1'}
  permissions
end

#social_media_1_permissionsObject



42
43
44
45
46
47
# File 'lib/generators/permissify/product/template/products.rb', line 42

def social_media_1_permissions
  permissions = Ability.create_permissions_hash([], %w(social_media facebook twitter), %w(Product Role))
  permissions['social_media_setup'] = {'0' => '1'}
  permissions['social_media_view'] = {'0' => '1'}
  permissions
end

#social_media_2_permissionsObject



48
49
50
51
52
53
54
# File 'lib/generators/permissify/product/template/products.rb', line 48

def social_media_2_permissions
  permissions = social_media_1_permissions
  permissions['social_media_create'] = {'0' => '1'}
  permissions['facebook_post'] = {'0' => '1'}
  permissions['twitter_tweet'] = {'0' => '1'}
  permissions
end

#social_media_3_permissionsObject



55
56
57
# File 'lib/generators/permissify/product/template/products.rb', line 55

def social_media_3_permissions
  Ability.create_permissions_hash([], %w(social_media_repeat), %w(Product Role))
end

#webpage_builder_permissionsObject



37
# File 'lib/generators/permissify/product/template/products.rb', line 37

def webpage_builder_permissions; ph :webpage_builder_on; end