Class: VersionedRoutes::VersionedRoutesInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/versioned_routes/versioned_routes_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ VersionedRoutesInfo

Returns a new instance of VersionedRoutesInfo.



7
8
9
10
11
# File 'lib/versioned_routes/versioned_routes_info.rb', line 7

def initialize(number)
  @number = number
  @block = nil
  @paths = Hash.new { |h, k| h[k] = Set.new }
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



5
6
7
# File 'lib/versioned_routes/versioned_routes_info.rb', line 5

def block
  @block
end

#numberObject

Returns the value of attribute number.



5
6
7
# File 'lib/versioned_routes/versioned_routes_info.rb', line 5

def number
  @number
end

#pathsObject

Returns the value of attribute paths.



5
6
7
# File 'lib/versioned_routes/versioned_routes_info.rb', line 5

def paths
  @paths
end

Instance Method Details

#append(mapping) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/versioned_routes/versioned_routes_info.rb', line 13

def append(mapping)
  verb = mapping.make_route(nil, nil).verb
  regex = mapping.path.to_regexp
  return false if paths[verb].include? regex
  paths[verb] << regex
  true
end