| Class | ActionController::Routing::Segment |
| In: |
vendor/rails/actionpack/lib/action_controller/routing.rb
|
| Parent: | Object |
| is_optional | -> | optional? |
| is_optional | [RW] |
# File vendor/rails/actionpack/lib/action_controller/routing.rb, line 542
542: def initialize
543: self.is_optional = false
544: end
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.
# 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.
# 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
# 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.
# 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
# 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.
# File vendor/rails/actionpack/lib/action_controller/routing.rb, line 588
588: def optionality_implied?
589: false
590: end