Module: Roles::DataMapper::ClassMethods
- Defined in:
- lib/roles_data_mapper/base.rb
Constant Summary collapse
- MAP =
{ :admin_flag => "property :admin_flag, ::DataMapper::Property::Flag[:admin, :guest]", :roles_mask => "property :roles_mask, Integer, :default => 0", :role_string => "property :role_string, String", :roles_string => "property :roles_string, String" }
Instance Method Summary collapse
- #strategy(name, options = {}) ⇒ Object
- #valid_multi_strategies ⇒ Object
- #valid_single_strategies ⇒ Object
- #valid_strategies ⇒ Object
Instance Method Details
#strategy(name, options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/roles_data_mapper/base.rb', line 36 def strategy name, ={} strategy_name = name.to_sym raise ArgumentError, "Unknown role strategy #{strategy_name}" if !valid_strategies.include? strategy_name use_roles_strategy strategy_name set_role_class(strategy_name, ) if strategies_with_role_class.include? strategy_name if == :default && MAP[name] instance_eval MAP[name] end set_role_strategy name, end |
#valid_multi_strategies ⇒ Object
28 29 30 |
# File 'lib/roles_data_mapper/base.rb', line 28 def valid_multi_strategies [:many_roles, :roles_mask] end |
#valid_single_strategies ⇒ Object
24 25 26 |
# File 'lib/roles_data_mapper/base.rb', line 24 def valid_single_strategies [:admin_flag, :one_role, :role_string] end |
#valid_strategies ⇒ Object
32 33 34 |
# File 'lib/roles_data_mapper/base.rb', line 32 def valid_strategies valid_single_strategies + valid_multi_strategies end |