Class: Pakyow::Routing::Route::EndpointBuilder
- Inherits:
-
Object
- Object
- Pakyow::Routing::Route::EndpointBuilder
- Defined in:
- lib/pakyow/routing/route.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #call(**params) ⇒ Object
-
#initialize(route:, path:) ⇒ EndpointBuilder
constructor
A new instance of EndpointBuilder.
- #source_location ⇒ Object
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
#params ⇒ Object (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_location ⇒ Object
79 80 81 |
# File 'lib/pakyow/routing/route.rb', line 79 def source_location @route.block&.source_location || [] end |