Class: Pakyow::Routing::Route::EndpointBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route:, path:) ⇒ EndpointBuilder

Returns a new instance of EndpointBuilder.



66
67
68
69
70
71
72
73
# File 'lib/pakyow/routing/route.rb', line 66

def initialize(route:, path:)
  @route, @path = route, path
  @params = String.normalize_path(File.join(@path.to_s, @route.path)).split("/").select { |segment|
    segment.include?(":")
  }.map { |segment|
    segment[(segment.index(":") + 1)..-1].to_sym
  }
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



64
65
66
# File 'lib/pakyow/routing/route.rb', line 64

def params
  @params
end

Instance Method Details

#call(**params) ⇒ Object



75
76
77
# File 'lib/pakyow/routing/route.rb', line 75

def call(**params)
  @route.build_path(@path, **params)
end

#source_locationObject



79
80
81
# File 'lib/pakyow/routing/route.rb', line 79

def source_location
  @route.block&.source_location || []
end