Module: Bali::Statics::ScopeRuler

Included in:
Rules
Defined in:
lib/bali/statics/scope_ruler.rb

Defined Under Namespace

Modules: HelperFunctions

Instance Method Summary collapse

Instance Method Details

#rule_scope(arg1, arg2 = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bali/statics/scope_ruler.rb', line 26

def rule_scope(arg1, arg2 = nil)
  data, actor = HelperFunctions.extract_data_and_actor(self, arg1, arg2)
  return unless data

  scope = HelperFunctions.scope_for(data)
  scoped_data = case scope.arity
                when 0 then scope.call
                when 1 then scope.call(data)
                when 2 then scope.call(data, actor)
                end

  scoped_data || data
end