Module: ResourcesController::ClassMethods
- Defined in:
- lib/resources_controller.rb
Instance Method Summary collapse
-
#nested_in(*names, &block) ⇒ Object
Specifies that this controller has a particular enclosing resource.
Instance Method Details
#nested_in(*names, &block) ⇒ Object
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.
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
# File 'lib/resources_controller.rb', line 524 def nested_in(*names, &block) = names. raise ArgumentError, "when giving more than one nesting, you may not specify options or a block" if names.length > 1 and (block_given? or .length > 0) # convert :polymorphic option to '?' if .delete(:polymorphic) raise ArgumentError, "when specifying :polymorphic => true, no block or other options may be given" if block_given? or .length > 0 names = ["?#{names.first}"] end # ignore first '*' if it has already been specified by :load_enclosing == true names.shift if specifications == ['*'] && names.first == '*' names.each do |name| ensure_sane_wildcard if name == '*' specifications << (name.to_s =~ /^(\*|\?(.*))$/ ? name.to_s : Specification.new(name, , &block)) end end |