Module: TroleGroups::Macros

Defined in:
lib/trole_groups/macros.rb,
lib/trole_groups/macros/static_roles.rb,
lib/trole_groups/macros/configuration.rb,
lib/trole_groups/macros/configuration/base_loader.rb,
lib/trole_groups/macros/configuration/config_loader.rb,
lib/trole_groups/macros/configuration/storage_loader.rb,
lib/trole_groups/macros/configuration/strategy_loader.rb

Defined Under Namespace

Modules: StaticRoleGroups Classes: Configuration

Instance Method Summary collapse

Instance Method Details

#trolegroups_strategy(strategy, options = {}) {|trolegroups_config| ... } ⇒ Object

Yields:

  • (trolegroups_config)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/trole_groups/macros.rb', line 18

def trolegroups_strategy strategy, options = {}, &block
  configuration = Configuration.new self, strategy, options

  configuration.load_adapter
  # puts "strategy module: #{configuration.strategy_module}" 
  begin
    self.send :include, configuration.strategy_module
  rescue
    puts "error loading strategy: #{configuration.strategy_module}"
  end

  configuration.define_hooks
  configuration.apply_strategy_options!

  if strategy == :bit_one 
    trolegroups_config.valid_roles = [:user, :admin] # default binary roles 
  end
  
  yield trolegroups_config if block_given?
  trolegroups_config
end