Module: Bali::Statics::ScopeRuler::HelperFunctions

Extended by:
HelperFunctions
Included in:
HelperFunctions
Defined in:
lib/bali/statics/scope_ruler.rb

Instance Method Summary collapse

Instance Method Details

#extract_data_and_actor(obj, arg1, arg2 = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/bali/statics/scope_ruler.rb', line 5

def extract_data_and_actor(obj, arg1, arg2 = nil)
  if arg2.nil?
    data = arg1
    if obj.respond_to?(:current_user)
      actor = obj.current_user
    end
  else
    data, actor = arg1, arg2
  end

  return data, actor
end

#scope_for(relation) ⇒ Object



18
19
20
21
22
23
# File 'lib/bali/statics/scope_ruler.rb', line 18

def scope_for(relation)
  rule_class = Bali::Rules.for(relation.model)
  return unless rule_class

  rule_class.inheritable_role.scope
end