Class: RouteNGNClient::URIMatcher
- Inherits:
-
Model
- Object
- Model
- RouteNGNClient::URIMatcher
show all
- Includes:
- Comparable
- Defined in:
- lib/routengn_client/models/uri_matcher.rb
Constant Summary
collapse
%(contact from request)
Instance Attribute Summary
Attributes inherited from Model
#attributes, #request_account_id
#children, #only_children, #parents
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #to_hash, #to_json, #to_log
#belongs_to, #from_hash, #from_json, #has_many, #has_one
Methods included from Logging
#init_logger, #logger
Instance Method Details
#<=>(other) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/routengn_client/models/uri_matcher.rb', line 9
def <=>(other)
if @attributes. == other.attributes.
case (@attributes.weight <=> other.attributes.weight)
when 0
@attributes.id.to_s <=> other.attributes.id.to_s
when 1 -1
when -1 1
else
0
end
else
return 0 if !HEADER_ORDER.include?(@attributes.) && !HEADER_ORDER.include?(other.attributes.)
return -1 if !HEADER_ORDER.include?(@attributes.)
return 1 if !HEADER_ORDER.include?(other.attributes.)
return (HEADER_ORDER.index(@attributes.) <=> HEADER_ORDER.index(other.attributes.))
end
end
|
#matches?(args = {}) ⇒ Boolean
33
34
35
36
37
38
39
|
# File 'lib/routengn_client/models/uri_matcher.rb', line 33
def matches?(args = {})
return false if !self.(args[:header])
return false if !@attributes.prefix.blank? && !self.matches_prefix?(args[:prefix])
return false if !@attributes.user_params.blank? && !self.matches_user_params?(args[:user_params])
return false if !@attributes.uri_params.blank? && !self.matches_uri_params?(args[:uri_params])
return true
end
|
41
42
43
|
# File 'lib/routengn_client/models/uri_matcher.rb', line 41
def (arg)
!@attributes..blank? && !arg.blank? && @attributes. == arg
end
|
#matches_prefix?(arg) ⇒ Boolean
45
46
47
|
# File 'lib/routengn_client/models/uri_matcher.rb', line 45
def matches_prefix?(arg)
@attributes.prefix == arg
end
|
#matches_uri_params?(arg) ⇒ Boolean
59
60
61
62
63
64
65
66
67
|
# File 'lib/routengn_client/models/uri_matcher.rb', line 59
def matches_uri_params?(arg)
if arg.is_a?(String)
@attributes.uri_params == arg
elsif arg.is_a?(Array)
arg.include?(@attributes.uri_params)
else
false
end
end
|
#matches_user_params?(arg) ⇒ Boolean
49
50
51
52
53
54
55
56
57
|
# File 'lib/routengn_client/models/uri_matcher.rb', line 49
def matches_user_params?(arg)
if arg.is_a?(String)
@attributes.user_params == arg
elsif arg.is_a?(Array)
arg.include?(@attributes.user_params)
else
false
end
end
|
#weight ⇒ Object
29
30
31
|
# File 'lib/routengn_client/models/uri_matcher.rb', line 29
def weight
@weight ||= [@attributes.prefix, @attributes.user_params, @attributes.uri_params].select { |x| !x.blank? }.length
end
|