Class ActionController::Routing::Segment
In: vendor/rails/actionpack/lib/action_controller/routing.rb
Parent: Object

Methods

External Aliases

is_optional -> optional?

Attributes

is_optional  [RW] 

Public Class methods

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 542
542:       def initialize
543:         self.is_optional = false
544:       end

Public Instance methods

Return an if condition that is true if all the prior segments can be generated. If there are no optional segments before this one, then nil is returned.

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 573
573:       def all_optionals_available_condition(prior_segments)
574:         optional_locals = prior_segments.collect { |s| s.local_name if s.optional? && s.respond_to?(:local_name) }.compact
575:         optional_locals.empty? ? nil : " if #{optional_locals * ' && '}"
576:       end

Continue generating string for the prior segments.

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 551
551:       def continue_string_structure(prior_segments)
552:         if prior_segments.empty?
553:           interpolation_statement(prior_segments)
554:         else
555:           new_priors = prior_segments[0..-2]
556:           prior_segments.last.string_structure(new_priors)
557:         end
558:       end

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 546
546:       def extraction_code
547:         nil
548:       end

Return a string interpolation statement for this segment and those before it.

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 561
561:       def interpolation_statement(prior_segments)
562:         chunks = prior_segments.collect { |s| s.interpolation_chunk }
563:         chunks << interpolation_chunk
564:         "\"#{chunks * ''}\"#{all_optionals_available_condition(prior_segments)}"
565:       end

Recognition

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 580
580:       def match_extraction(next_capture)
581:         nil
582:       end

Returns true if this segment is optional? because of a default. If so, then no warning will be emitted regarding this segment.

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 588
588:       def optionality_implied?
589:         false
590:       end

[Source]

     # File vendor/rails/actionpack/lib/action_controller/routing.rb, line 567
567:       def string_structure(prior_segments)
568:         optional? ? continue_string_structure(prior_segments) : interpolation_statement(prior_segments)
569:       end

[Validate]