Class: Granite::Routing::Route

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(projector_path, path: nil, as: nil, projector_prefix: false) ⇒ Route

Returns a new instance of Route.



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

def initialize(projector_path, path: nil, as: nil, projector_prefix: false)
  @projector_path = projector_path
  @action_path, @projector_name = projector_path.split('#')
  @path = path
  @as = as

  @action_name = @action_path.split('/').last
  @action_name = "#{@projector_name}_#{@action_name}" if projector_prefix
end

Instance Attribute Details

#action_pathObject (readonly)

Returns the value of attribute action_path.



4
5
6
# File 'lib/granite/routing/route.rb', line 4

def action_path
  @action_path
end

#projector_nameObject (readonly)

Returns the value of attribute projector_name.



4
5
6
# File 'lib/granite/routing/route.rb', line 4

def projector_name
  @projector_name
end

#projector_pathObject (readonly)

Returns the value of attribute projector_path.



4
5
6
# File 'lib/granite/routing/route.rb', line 4

def projector_path
  @projector_path
end

Instance Method Details

#asObject



20
21
22
# File 'lib/granite/routing/route.rb', line 20

def as
  @as || action_name
end

#pathObject



16
17
18
# File 'lib/granite/routing/route.rb', line 16

def path
  "#{@path || action_name}(/:projector_action)"
end