Class: Para::Routing::ComponentControllerConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/para/routing/component_controller_constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ ComponentControllerConstraint

Returns a new instance of ComponentControllerConstraint.



13
14
15
# File 'lib/para/routing/component_controller_constraint.rb', line 13

def initialize(controller)
  @controller = controller.to_sym
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



11
12
13
# File 'lib/para/routing/component_controller_constraint.rb', line 11

def controller
  @controller
end

Instance Method Details

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/para/routing/component_controller_constraint.rb', line 17

def matches?(request)
  component = component_for(request.params[:component_id])
  return false unless component && component.controller
  component.controller.to_sym == controller
end