Class: Postnhost::Constraints::PublicRouteConstraint

Inherits:
Object
  • Object
show all
Defined in:
app/services/postnhost/constraints/public_route_constraint.rb

Instance Method Summary collapse

Constructor Details

#initialize(kind:, parameter:) ⇒ PublicRouteConstraint

Returns a new instance of PublicRouteConstraint.



4
5
6
7
# File 'app/services/postnhost/constraints/public_route_constraint.rb', line 4

def initialize(kind:, parameter:)
  @kind = kind
  @parameter = parameter
end

Instance Method Details

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'app/services/postnhost/constraints/public_route_constraint.rb', line 9

def matches?(request)
  slug = request.params.fetch(parameter)
  Postnhost::PublicRequestContext.for(request).resolve_kind(kind, slug).present?
end