Class: Only::BaseConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/only/base_constraint.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.requestObject

Returns the value of attribute request.



4
5
6
# File 'lib/only/base_constraint.rb', line 4

def request
  @request
end

Class Method Details

.matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/only/base_constraint.rb', line 6

def matches?(request)
  self.request = request
  condition_matches?
end

.params(attribute = nil) ⇒ Object



16
17
18
# File 'lib/only/base_constraint.rb', line 16

def params(attribute = nil)
  attribute ? request.params[attribute] : request.params
end

.requested_domainObject

Get the domain name from the request URL



12
13
14
# File 'lib/only/base_constraint.rb', line 12

def requested_domain
  %r{//([^/]+)}.match(request.url)[1]
end