Class: RouteTranslator::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/route_translator/route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_set, path, name, options_constraints, options, mapping) ⇒ Route

Returns a new instance of Route.



7
8
9
10
11
12
13
14
# File 'lib/route_translator/route.rb', line 7

def initialize(route_set, path, name, options_constraints, options, mapping)
  @route_set           = route_set
  @path                = path
  @name                = name
  @options_constraints = options_constraints
  @options             = options
  @mapping             = mapping
end

Instance Attribute Details

#mappingObject (readonly)

Returns the value of attribute mapping.



5
6
7
# File 'lib/route_translator/route.rb', line 5

def mapping
  @mapping
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/route_translator/route.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/route_translator/route.rb', line 5

def options
  @options
end

#options_constraintsObject (readonly)

Returns the value of attribute options_constraints.



5
6
7
# File 'lib/route_translator/route.rb', line 5

def options_constraints
  @options_constraints
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/route_translator/route.rb', line 5

def path
  @path
end

#route_setObject (readonly)

Returns the value of attribute route_set.



5
6
7
# File 'lib/route_translator/route.rb', line 5

def route_set
  @route_set
end

Instance Method Details

#scopeObject



16
17
18
19
20
21
22
23
# File 'lib/route_translator/route.rb', line 16

def scope
  @scope ||=
    if mapping.defaults[:controller]
      %i[routes controllers].concat mapping.defaults[:controller].split('/').map(&:to_sym)
    else
      %i[routes controllers]
    end
end