Class: Proximity::Router::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/proximity/router.rb

Instance Method Summary collapse

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

#matchesObject



29
30
31
# File 'lib/proximity/router.rb', line 29

def matches
  @match[1]
end

#presenceObject



43
44
45
# File 'lib/proximity/router.rb', line 43

def presence
  @matches.empty? ? nil : self
end

#proxyObject



39
40
41
# File 'lib/proximity/router.rb', line 39

def proxy
  @match[2].proxy
end

#targetObject



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