Class: ResourcesController::SingletonResourceService
- Inherits:
-
ResourceService
- Object
- ResourceService
- ResourcesController::SingletonResourceService
- Defined in:
- lib/resources_controller.rb
Instance Attribute Summary
Attributes inherited from ResourceService
Instance Method Summary collapse
- #destroy(*args, **kwargs) ⇒ Object
- #find(*args, **kwargs) ⇒ Object
-
#new(*args, **kwargs, &block) ⇒ Object
build association on the enclosing resource if there is one, otherwise call new.
- #service ⇒ Object
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, **kwargs) ⇒ Object
806 807 808 |
# File 'lib/resources_controller.rb', line 806 def destroy(*args, **kwargs) find.destroy end |
#find(*args, **kwargs) ⇒ Object
787 788 789 790 791 792 793 794 795 |
# File 'lib/resources_controller.rb', line 787 def find(*args, **kwargs) 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, **kwargs, &block) ⇒ Object
build association on the enclosing resource if there is one, otherwise call new
798 799 800 801 802 803 804 |
# File 'lib/resources_controller.rb', line 798 def new(*args, **kwargs, &block) if enclosing_resource enclosing_resource.send("build_#{resource_specification.source}", *args, **kwargs, &block) else service.new(*args, **kwargs, &block) end end |
#service ⇒ Object
810 811 812 |
# File 'lib/resources_controller.rb', line 810 def service resource_class end |