Class: ResourcesController::SingletonResourceService

Inherits:
ResourceService
  • Object
show all
Defined in:
lib/resources_controller.rb

Instance Attribute Summary

Attributes inherited from ResourceService

#controller

Instance Method Summary collapse

Methods inherited from ResourceService

#initialize, #method_missing, #respond_to?

Constructor Details

This class inherits a constructor from ResourcesController::ResourceService

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ResourcesController::ResourceService

Instance Method Details

#destroy(*args) ⇒ Object

[View source] [View on GitHub]

797
798
799
# File 'lib/resources_controller.rb', line 797

def destroy(*args)
  find.destroy
end

#find(*args) ⇒ Object

[View source] [View on GitHub]

782
783
784
785
786
787
788
789
790
# File 'lib/resources_controller.rb', line 782

def find(*args)
  if resource_specification.find
    resource_specification.find_custom(controller)
  elsif controller.enclosing_resources.size > 0
    enclosing_resource.send(resource_specification.source)
  else
    ::ResourcesController.raise_cant_find_singleton(controller.resource_name, controller.resource_class)
  end
end

#new(*args, &block) ⇒ Object

build association on the enclosing resource if there is one, otherwise call new

[View source] [View on GitHub]

793
794
795
# File 'lib/resources_controller.rb', line 793

def new(*args, &block)
  enclosing_resource ? enclosing_resource.send("build_#{resource_specification.source}", *args, &block) : service.new(*args, &block)
end

#serviceObject

[View source] [View on GitHub]

801
802
803
# File 'lib/resources_controller.rb', line 801

def service
  resource_class
end