Module: Zuul::ActiveRecord::ClassMethods
- Defined in:
- lib/zuul/active_record.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#acts_as_authorization_context(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization context (or resource).
-
#acts_as_authorization_context? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization context/resource.
-
#acts_as_authorization_model(args = {}, &block) ⇒ Object
Includes auth methods into the model and configures auth options and scopes.
- #acts_as_authorization_model?(type) ⇒ Boolean
-
#acts_as_authorization_permission(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization permission.
-
#acts_as_authorization_permission? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization permission.
-
#acts_as_authorization_permission_role(args = {}, &block) ⇒ Object
Configure the model to act as a zuul joining model for roles and subjects.
-
#acts_as_authorization_permission_role? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization permission_role.
-
#acts_as_authorization_permission_subject(args = {}, &block) ⇒ Object
Configure the model to act as a zuul joining model for roles and subjects.
-
#acts_as_authorization_permission_subject? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization permission_subject.
-
#acts_as_authorization_role(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization role.
-
#acts_as_authorization_role? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization role.
-
#acts_as_authorization_role_subject(args = {}, &block) ⇒ Object
Configure the model to act as a zuul joining model for roles and subjects.
-
#acts_as_authorization_role_subject? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization role_subject.
-
#acts_as_authorization_subject(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization subject.
-
#acts_as_authorization_subject? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization subject.
-
#prepare_join_classes(scope) ⇒ Object
Sets up the join models for a newly defined scope.
Class Method Details
.extended(base) ⇒ Object
19 20 |
# File 'lib/zuul/active_record.rb', line 19 def self.extended(base) end |
Instance Method Details
#acts_as_authorization_context(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization context (or resource)
The args parameter is an optional hash of configuration options.
64 65 66 67 68 |
# File 'lib/zuul/active_record.rb', line 64 def (args={}, &block) scope = (args, &block) prepare_join_classes scope.name include Context end |
#acts_as_authorization_context? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization context/resource
136 137 138 |
# File 'lib/zuul/active_record.rb', line 136 def :context end |
#acts_as_authorization_model(args = {}, &block) ⇒ Object
Includes auth methods into the model and configures auth options and scopes
The args parameter is an optional hash of configuration options.
25 26 27 28 29 30 31 32 |
# File 'lib/zuul/active_record.rb', line 25 def (args={}, &block) include AuthorizationMethods unless ancestors.include?(AuthorizationMethods) auth_config = Zuul.configuration.clone.configure(args, &block) @auth_scopes ||= {} @auth_scopes[auth_config.scope] = Scope.new(auth_config) @auth_scopes[:default] ||= @auth_scopes[auth_config.scope] @auth_scopes[auth_config.scope] end |
#acts_as_authorization_model?(type) ⇒ Boolean
121 122 123 |
# File 'lib/zuul/active_record.rb', line 121 def (type) ancestors.include?("zuul/active_record/#{type}".camelize.constantize) end |
#acts_as_authorization_permission(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization permission
The args parameter is an optional hash of configuration options.
46 47 48 49 50 |
# File 'lib/zuul/active_record.rb', line 46 def (args={}, &block) scope = (args.merge({:permission_class => self.name}), &block) prepare_join_classes scope.name include Permission end |
#acts_as_authorization_permission? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization permission
131 132 133 |
# File 'lib/zuul/active_record.rb', line 131 def :permission end |
#acts_as_authorization_permission_role(args = {}, &block) ⇒ Object
Configure the model to act as a zuul joining model for roles and subjects
The args parameter is an optional hash of configuration options.
73 74 75 76 |
# File 'lib/zuul/active_record.rb', line 73 def (args={}, &block) scope = (args.merge({:permission_role_class => self.name}), &block) include PermissionRole end |
#acts_as_authorization_permission_role? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization permission_role
156 157 158 |
# File 'lib/zuul/active_record.rb', line 156 def :permission_role end |
#acts_as_authorization_permission_subject(args = {}, &block) ⇒ Object
Configure the model to act as a zuul joining model for roles and subjects
The args parameter is an optional hash of configuration options.
81 82 83 84 |
# File 'lib/zuul/active_record.rb', line 81 def (args={}, &block) scope = (args.merge({:permission_subject_class => self.name}), &block) include PermissionSubject end |
#acts_as_authorization_permission_subject? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization permission_subject
151 152 153 |
# File 'lib/zuul/active_record.rb', line 151 def :permission_subject end |
#acts_as_authorization_role(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization role
The args parameter is an optional hash of configuration options.
37 38 39 40 41 |
# File 'lib/zuul/active_record.rb', line 37 def (args={}, &block) scope = (args.merge({:role_class => self.name}), &block) prepare_join_classes scope.name include Role end |
#acts_as_authorization_role? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization role
126 127 128 |
# File 'lib/zuul/active_record.rb', line 126 def :role end |
#acts_as_authorization_role_subject(args = {}, &block) ⇒ Object
Configure the model to act as a zuul joining model for roles and subjects
The args parameter is an optional hash of configuration options.
89 90 91 92 |
# File 'lib/zuul/active_record.rb', line 89 def (args={}, &block) scope = (args.merge({:role_subject_class => self.name}), &block) include RoleSubject end |
#acts_as_authorization_role_subject? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization role_subject
146 147 148 |
# File 'lib/zuul/active_record.rb', line 146 def :role_subject end |
#acts_as_authorization_subject(args = {}, &block) ⇒ Object
Configure the model to act as a zuul authorization subject
The args parameter is an optional hash of configuration options.
55 56 57 58 59 |
# File 'lib/zuul/active_record.rb', line 55 def (args={}, &block) scope = (args.merge({:subject_class => self.name}), &block) prepare_join_classes scope.name include Subject end |
#acts_as_authorization_subject? ⇒ Boolean
Checks if the model is setup to act as a zuul authorization subject
141 142 143 |
# File 'lib/zuul/active_record.rb', line 141 def :subject end |
#prepare_join_classes(scope) ⇒ Object
Sets up the join models for a newly defined scope.
This is similar the the acts_as_authorization_* methods, but it handles all the joining models for a scope.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/zuul/active_record.rb', line 97 def prepare_join_classes(scope) scope_config = auth_scope(scope).config unless auth_scope(scope).role_subject_class. auth_scope(scope).role_subject_class.instance_eval do (scope_config.to_h) end end if auth_scope(scope).config. unless auth_scope(scope).. auth_scope(scope)..instance_eval do (scope_config.to_h) end end unless auth_scope(scope).. auth_scope(scope)..instance_eval do (scope_config.to_h) end end end end |