Class: Authorization::ObligationScope
- Inherits:
-
ActiveRecord::NamedScope::Scope
- Object
- ActiveRecord::NamedScope::Scope
- Authorization::ObligationScope
- Defined in:
- lib/declarative_authorization/obligation_scope.rb,
lib/declarative_authorization/obligation_scope.rb,
lib/declarative_authorization/obligation_scope.rb
Instance Method Summary collapse
-
#initialize(model, options) ⇒ ObligationScope
constructor
A new instance of ObligationScope.
-
#parse!(obligation) ⇒ Object
Consumes the given obligation, converting it into scope join and condition options.
- #scope ⇒ Object
Constructor Details
#initialize(model, options) ⇒ ObligationScope
Returns a new instance of ObligationScope.
54 55 56 57 58 59 60 61 |
# File 'lib/declarative_authorization/obligation_scope.rb', line 54 def initialize (model, ) @finder_options = {} if Rails.version < "3" super(model, ) else super(model, model.table_name) end end |
Instance Method Details
#parse!(obligation) ⇒ Object
Consumes the given obligation, converting it into scope join and condition options.
73 74 75 76 77 78 79 80 81 |
# File 'lib/declarative_authorization/obligation_scope.rb', line 73 def parse!( obligation ) @current_obligation = obligation @join_table_joins = Set.new obligation_conditions[@current_obligation] ||= {} follow_path( obligation ) end |
#scope ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/declarative_authorization/obligation_scope.rb', line 63 def scope if Rails.version < "3" self else # for Rails < 3: scope, after setting proxy_options self.klass.scoped(@finder_options) end end |