Module: Cream::GeneratorHelper::Strategy

Defined in:
lib/generators/cream/helpers/strategy_helper.rb

Instance Method Summary collapse

Instance Method Details

#basic_strategiesObject



50
51
52
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 50

def basic_strategies
  [:admin_flag, :role_string, :one_role, :many_roles, :roles_mask, :roles_string]
end

#document_store_strategiesObject



54
55
56
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 54

def document_store_strategies 
  [:embed_one_role, :embed_many_roles, :role_strings]
end

#document_store_strategy?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 30

def document_store_strategy?
  document_store_strategies.include? strategy
end

#embed_strategy?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 26

def embed_strategy?
  role_embed_strategies.include? strategy
end

#inline_strategiesObject



46
47
48
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 46

def inline_strategies
  valid_strategies - role_ref_strategies - role_embed_strategies
end

#inline_strategy?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 34

def inline_strategy?
  document_store_strategies.include? strategy
end

#role_embed_strategiesObject



42
43
44
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 42

def role_embed_strategies
  [:embed_one_role, :embed_many_roles]
end

#role_ref_strategiesObject



38
39
40
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 38

def role_ref_strategies
  [:one_role, :many_roles]
end

#role_ref_strategy?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 22

def role_ref_strategy?
  role_ref_strategies.include? strategy
end

#valid_strategiesObject



16
17
18
19
20
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 16

def valid_strategies
  @strategies ||= basic_strategies
  @strategies << document_store_strategies if document_store?
  @strategies
end

#valid_strategies_listObject



12
13
14
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 12

def valid_strategies_list
  valid_strategies.map(&:to_s).join(', ')
end

#validate_strategyObject



4
5
6
7
8
9
10
# File 'lib/generators/cream/helpers/strategy_helper.rb', line 4

def validate_strategy
   if !valid_strategies.include?(strategy.to_sym)
     say "ERROR: Strategy '#{strategy}' is not currently supported by Cream. Please use one of: #{valid_strategies_list}", :red
     return false
   end
   true
end