Class: Authorization::ObligationScope

Inherits:
ActiveRecord::NamedScope::Scope
  • Object
show all
Defined in:
lib/declarative_authorization/obligation_scope.rb,
lib/declarative_authorization/obligation_scope.rb,
lib/declarative_authorization/obligation_scope.rb

Instance Method Summary collapse

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, options)
  @finder_options = {}
  if Rails.version < "3"
    super(model, options)
  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 )

  rebuild_condition_options!
  rebuild_join_options!
end

#scopeObject



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