Class: Waffle::Maker::Matcher
- Inherits:
-
Object
- Object
- Waffle::Maker::Matcher
- Defined in:
- lib/waffle/maker/matcher.rb
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
-
#waf_path ⇒ Object
readonly
Returns the value of attribute waf_path.
Instance Method Summary collapse
-
#initialize(waf_path, routes) ⇒ Matcher
constructor
A new instance of Matcher.
- #matched? ⇒ Boolean
- #rep_regex ⇒ Object
Constructor Details
#initialize(waf_path, routes) ⇒ Matcher
Returns a new instance of Matcher.
8 9 10 11 |
# File 'lib/waffle/maker/matcher.rb', line 8 def initialize(waf_path, routes) @waf_path = waf_path.to_s.chomp('/') @routes = routes end |
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
6 7 8 |
# File 'lib/waffle/maker/matcher.rb', line 6 def routes @routes end |
#waf_path ⇒ Object (readonly)
Returns the value of attribute waf_path.
6 7 8 |
# File 'lib/waffle/maker/matcher.rb', line 6 def waf_path @waf_path end |
Instance Method Details
#matched? ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/waffle/maker/matcher.rb', line 13 def matched? return true if routes.include?(waf_path) routes.any? do |route| -> { route = params_route_2_regex_route(route) return false if route.start_with?("/#{rep_regex}") /#{route}$/.match?(waf_path) }.call end end |
#rep_regex ⇒ Object
26 27 28 |
# File 'lib/waffle/maker/matcher.rb', line 26 def rep_regex '(\w+)' end |