Module Ardes::ResourcesController::ClassMethods
In: lib/ardes/resources_controller.rb

Methods

Public Instance methods

Specifies that this controller has a particular enclosing resource.

This can be called with an array of symbols (in which case options can‘t be specified) or a symbol with options.

See Specification#new for details of how to call this.

[Source]

     # File lib/ardes/resources_controller.rb, line 524
524:       def nested_in(*names, &block)
525:         options = names.extract_options!
526:         raise ArgumentError, "when giving more than one nesting, you may not specify options or a block" if names.length > 1 and (block_given? or options.length > 0)
527:         
528:         # convert :polymorphic option to '?'
529:         if options.delete(:polymorphic)
530:           raise ArgumentError, "when specifying :polymorphic => true, no block or other options may be given" if block_given? or options.length > 0
531:           names = ["?#{names.first}"] 
532:         end
533: 
534:         # ignore first '*' if it has already been specified by :load_enclosing == true
535:         names.shift if specifications == ['*'] && names.first == '*'
536:         
537:         names.each do |name|
538:           ensure_sane_wildcard if name == '*'
539:           specifications << (name.to_s =~ /^(\*|\?(.*))$/ ? name.to_s : Specification.new(name, options, &block))
540:         end
541:       end

return the class resource_specification

[Source]

     # File lib/ardes/resources_controller.rb, line 544
544:       def resource_specification
545:         read_inheritable_attribute(:resource_specification)
546:       end

Private Instance methods

ensure that specifications array is determinate w.r.t route matching

[Source]

     # File lib/ardes/resources_controller.rb, line 550
550:       def ensure_sane_wildcard
551:         idx = specifications.length
552:         while (idx -= 1) >= 0
553:           if specifications[idx] == '*'
554:             raise ArgumentError, "Can only specify one wildcard '*' in between resource specifications"
555:           elsif specifications[idx].is_a?(Specification)
556:             break
557:           end
558:         end
559:         true
560:       end

[Validate]