Class: PathParserService
- Inherits:
-
Object
- Object
- PathParserService
- Defined in:
- app/services/path_parser_service.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(template, path) ⇒ PathParserService
constructor
A new instance of PathParserService.
Constructor Details
#initialize(template, path) ⇒ PathParserService
Returns a new instance of PathParserService.
2 3 4 5 |
# File 'app/services/path_parser_service.rb', line 2 def initialize(template, path) @template = template @path = path end |
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/services/path_parser_service.rb', line 7 def call components = @path.match(path_parse_pattern)&.named_captures&.symbolize_keys return {} if components.nil? components.merge({ tags: components[:tags]&.split(File::SEPARATOR)&.compact_blank, collections: components[:collection] ? [components.delete(:collection)] : components[:collections]&.split("/")&.compact_blank, model_id: nil # discard ID, never gonna use it in parsing }).compact_blank end |