Module: TroleGroups::Config::Schema
- Includes:
- Helpers, RoleGroupHelpers
- Defined in:
- lib/trole_groups/config/schema.rb,
lib/trole_groups/config/schema/helpers.rb,
lib/trole_groups/config/schema/role_group_helpers.rb
Defined Under Namespace
Modules: Helpers, RoleGroupHelpers
Instance Method Summary collapse
-
#configure_field ⇒ Object
Adapter should customize this as needed.
- #configure_generic ⇒ Object
- #configure_models ⇒ Object
-
#configure_relation ⇒ Object
Adapter should customize this as needed.
-
#rolegroup_model ⇒ Class
Gets the role model to be used see (#role_model=).
-
#rolegroup_model=(model_class) ⇒ Object
Sets the role model to use allows different role subject classes (fx User Accounts) to have different role schemas.
Methods included from RoleGroupHelpers
Methods included from Helpers
Instance Method Details
#configure_field ⇒ Object
Adapter should customize this as needed
18 19 |
# File 'lib/trole_groups/config/schema.rb', line 18 def configure_field end |
#configure_generic ⇒ Object
13 14 15 |
# File 'lib/trole_groups/config/schema.rb', line 13 def configure_generic subject_class.send(:attr_accessor, role_field) if generic? || orm == :generic # create troles accessor end |
#configure_models ⇒ Object
7 8 9 10 11 |
# File 'lib/trole_groups/config/schema.rb', line 7 def configure_models configure_generic configure_field if auto_config?(:fields) configure_relation if auto_config?(:relations) end |
#configure_relation ⇒ Object
Adapter should customize this as needed
22 23 |
# File 'lib/trole_groups/config/schema.rb', line 22 def configure_relation end |
#rolegroup_model ⇒ Class
Gets the role model to be used see (#role_model=)
36 37 38 39 40 41 42 43 44 |
# File 'lib/trole_groups/config/schema.rb', line 36 def rolegroup_model @rolegroup_model_found ||= begin models = [@rolegroup_model, role_group_class_name].select do |class_name| try_class(class_name.to_s.camelize) end.compact raise "No #{role_group_class_name} class defined, define a #{role_group_class_name} class or set which class to use, using the :rolegroup_model option on configuration" if models.empty? models.first.to_s.constantize end end |
#rolegroup_model=(model_class) ⇒ Object
Sets the role model to use allows different role subject classes (fx User Accounts) to have different role schemas
28 29 30 31 |
# File 'lib/trole_groups/config/schema.rb', line 28 def rolegroup_model= model_class @rolegroup_model = model_class.to_s and return if model_class.any_kind_of?(Class, String, Symbol) raise "The rolegroup model must be a Class, was: #{model_class}" end |