Class: BonaFide::Constraint

Inherits:
Object
  • Object
show all
Defined in:
lib/bona_fide/constraint.rb

Instance Method Summary collapse

Constructor Details

#initialize(getter) ⇒ Constraint

Sets up a constraint for use with ActionDispatch::Routing. Pass in a method, getter, to be called on the specified base_class for the current BonaFide session.



6
7
8
# File 'lib/bona_fide/constraint.rb', line 6

def initialize(getter)
  @getter = getter
end

Instance Method Details

#matches?(request) ⇒ Boolean

Called from ActionDispatch::Routing, calls the requested getter method on the BonaFide::Configuration base_class. The response should be either true or false.

Returns:

  • (Boolean)


13
14
15
# File 'lib/bona_fide/constraint.rb', line 13

def matches?(request)
  BonaFide.config.base_class.send(@getter)
end