Class: Proximity::Router::Match
- Inherits:
-
Object
- Object
- Proximity::Router::Match
- Defined in:
- lib/proximity/router.rb
Instance Method Summary collapse
-
#initialize(matches) ⇒ Match
constructor
A new instance of Match.
- #matches ⇒ Object
- #presence ⇒ Object
- #proxy ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize(matches) ⇒ Match
Returns a new instance of Match.
24 25 26 27 |
# File 'lib/proximity/router.rb', line 24 def initialize(matches) @matches = matches @match = matches.first end |
Instance Method Details
#matches ⇒ Object
29 30 31 |
# File 'lib/proximity/router.rb', line 29 def matches @match[1] end |
#presence ⇒ Object
43 44 45 |
# File 'lib/proximity/router.rb', line 43 def presence @matches.empty? ? nil : self end |
#proxy ⇒ Object
39 40 41 |
# File 'lib/proximity/router.rb', line 39 def proxy @match[2].proxy end |
#target ⇒ Object
33 34 35 36 37 |
# File 'lib/proximity/router.rb', line 33 def target matches.inject(proxy.target) { |target, (key, value)| target.gsub(":#{key}", value) } end |