Module: BreakDance::SecurityScoping::ClassMethods

Defined in:
lib/break_dance/security_scoping.rb

Instance Method Summary collapse

Instance Method Details

#scoped(options = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/break_dance/security_scoping.rb', line 6

def scoped(options = nil)
  scope = super(options)
  return ActiveRecord::Relation.new(self, Arel::Table.new(table_name)) unless scope

  sph = RequestStore.store[:security_policy_holder]
  if sph
    if sph.suppress_security_for == self.name
      sph.suppress_security_for = nil
      scope
    else
      scope.merge(sph.policies[self.name]).readonly(false)
    end
  else
    scope
  end
end

#unsecuredObject



23
24
25
26
# File 'lib/break_dance/security_scoping.rb', line 23

def unsecured
  RequestStore.store[:security_policy_holder].suppress_security_for = self.name
  scoped
end