class LuckyRouter::Fragment(T)
 
  - LuckyRouter::Fragment(T)
 - Reference
 - Object
 
Overview
A fragment represents possible combinations for a part of the path. The first/top fragment represents the first "part" of a path.
The fragment contains the possible static parts or a single dynamic part Each static part or dynamic part has another fragment, that represents the next set of fragments that could match. This is a bit confusing so let's dive into an example:
/users/foo/users/:id/posts/foo
The Fragment would represent the possible combinations for the first part
# 'nil' because there is no route with a dynamic part in the first slot
fragment.dynamic_part # nil
# This returns a Hash whose keys are the possible values, and a value for the
*next* Fragment
fragment.static_parts
# Would return:
{"users" => Fragment, "posts" => Fragment}
# The Fragment in the 'users' key would have:
# Fragment.new(PathPart(":id"))
fragment.dynamic_part
# Static parts
fragment.static_parts
{"foo" => Fragment}
Gotcha
The last fragment of a path is "empty". It does not have static parts or dynamic parts
Defined in:
lucky_router/fragment.crConstructors
Instance Method Summary
- #add_part(path_part : PathPart) : Fragment(T)
 - #collect_routes : Array(Tuple(Array(PathPart), String, T))
 - #dynamic? : Bool
 - #dynamic_parts
 - 
        #find(parts : Array(String), method : String) : Match(T) | NoMatch
        
          
This looks for a matching fragment for the given parts and returns NoMatch if one is not found
 - 
        #find(parts : Slice(String), method : String) : Match(T) | NoMatch
        
          
This looks for a matching fragment for the given parts and returns NoMatch if one is not found
 - #find_match(path_parts : Array(String), method : String) : Match(T) | Nil
 - #find_match(path_parts : Slice(String), method : String) : Match(T) | Nil
 - #glob_part : Fragment(T) | Nil
 - #glob_part=(glob_part : Fragment(T) | Nil)
 - #match_for_method(method)
 - 
        #method_to_payload
        
          
Every path can have multiple request methods and since each fragment represents a request path the final step to finding the payload is to search for a matching request method
 - #path_part : PathPart
 - #process_parts(parts : Array(PathPart), method : String, payload : T)
 - #static_parts
 
Constructor Detail
Instance Method Detail
This looks for a matching fragment for the given parts and returns NoMatch if one is not found
This looks for a matching fragment for the given parts and returns NoMatch if one is not found
Every path can have multiple request methods and since each fragment represents a request path the final step to finding the payload is to search for a matching request method