Class: Cassette::Rubycas::RoutingConstraint

Inherits:
Object
  • Object
show all
Includes:
UserFactory
Defined in:
lib/cassette/rubycas/routing_constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UserFactory

#from_session

Constructor Details

#initialize(role, opts = {}) ⇒ RoutingConstraint

Returns a new instance of RoutingConstraint


8
9
10
11
12
# File 'lib/cassette/rubycas/routing_constraint.rb', line 8

def initialize(role, opts = {})
  defaults = { raw: false }
  @role = role
  @options = defaults.merge(opts)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


6
7
8
# File 'lib/cassette/rubycas/routing_constraint.rb', line 6

def options
  @options
end

#roleObject (readonly)

Returns the value of attribute role


6
7
8
# File 'lib/cassette/rubycas/routing_constraint.rb', line 6

def role
  @role
end

Instance Method Details

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)

14
15
16
17
18
19
20
# File 'lib/cassette/rubycas/routing_constraint.rb', line 14

def matches?(request)
  user = from_session(request.session)

  meth = options[:raw] ? :has_raw_role? : :has_role?

  user.send(meth, role)
end