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



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

def destroy(*args)
  find.destroy
end

#find(*args) ⇒ Object



786
787
788
789
790
791
792
793
794
# File 'lib/resources_controller.rb', line 786

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



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

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

#serviceObject



805
806
807
# File 'lib/resources_controller.rb', line 805

def service
  resource_class
end