Class: ActionPolicy::Testing::AuthorizeTracker::Scoping

Inherits:
Object
  • Object
show all
Includes:
Context
Defined in:
lib/action_policy/testing.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(policy, target, type, name, scope_options) ⇒ Scoping

Returns a new instance of Scoping.



45
46
47
48
49
50
51
# File 'lib/action_policy/testing.rb', line 45

def initialize(policy, target, type, name, scope_options)
  @policy = policy
  @target = target
  @type = type
  @name = name
  @scope_options = scope_options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



43
44
45
# File 'lib/action_policy/testing.rb', line 43

def name
  @name
end

#policyObject (readonly)

Returns the value of attribute policy.



43
44
45
# File 'lib/action_policy/testing.rb', line 43

def policy
  @policy
end

#scope_optionsObject (readonly)

Returns the value of attribute scope_options.



43
44
45
# File 'lib/action_policy/testing.rb', line 43

def scope_options
  @scope_options
end

#targetObject (readonly)

Returns the value of attribute target.



43
44
45
# File 'lib/action_policy/testing.rb', line 43

def target
  @target
end

#typeObject (readonly)

Returns the value of attribute type.



43
44
45
# File 'lib/action_policy/testing.rb', line 43

def type
  @type
end

Instance Method Details

#inspectObject



61
62
63
# File 'lib/action_policy/testing.rb', line 61

def inspect
  "#{policy.class} :#{name} for :#{type} #{scope_options_message}"
end

#matches?(policy_class, actual_type, actual_name, actual_scope_options, actual_context) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
# File 'lib/action_policy/testing.rb', line 53

def matches?(policy_class, actual_type, actual_name, actual_scope_options, actual_context)
  policy_class == policy.class &&
    type == actual_type &&
    name == actual_name &&
    actual_scope_options === scope_options &&
    context_matches?(actual_context, policy.authorization_context)
end