Module: Cardiac::Model::Declarations
- Extended by:
- ActiveSupport::Concern
- Includes:
- Declarations
- Included in:
- Base
- Defined in:
- lib/cardiac/model/declarations.rb
Overview
Cardiac::Model declaration methods and resource extensions.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- RESOURCE_EXTENSION_BLOCK =
This extension block is used to build the base resource’s extension module.
Proc.new do ## # :method: find_instances # This member performs a GET, after merging any arguments into the query string. # This member is used by find(:all) and find_all operation :find_instances, lambda{|*query| query.any? ? query(*query).get : get } ## # :method: create_instance # This member performs a POST, using the given argument as the payload. # This member is used by create_record. operation :create_instance, lambda{|payload| post(payload) } ## # :method: identify # # This member identifies a singular subresource by converting the given argument # to a parameter and appending it to the path. Parameters are properly CGI escaped. # # This member is used by all query/persistence methods that operate on existing records. subresource :identify, lambda{|id_or_model| path(Array(id_or_model).map{|v| CGI.escape(v.to_param)}.to_param) } do ## # :method: update_instance # This member performs a PUT, using the given argument as the payload. # This member is used by update_record. operation :update_instance, lambda{|payload| put(payload) } ## # :method: delete_instance # This member performs a DELETE, after merging any arguments into the query string. # This member is used by delete and destroy. operation :delete_instance, lambda{|*query| query.any? ? query(*query).delete : delete } ## # :method: find_instance # This member performs a GET, after merging any arguments into the query string. # This member is used by find(:one), find(:some), find_one, find_some, and find_with_ids operation :find_instance, lambda{|*query| query.any? ? query(*query).get : get } end end
Instance Method Summary collapse
-
#base_resource ⇒ Object
Implement an instance’s base resource as a subresource of the class base resource.
Methods included from DeclarationMethods
Instance Method Details
#base_resource ⇒ Object
Implement an instance’s base resource as a subresource of the class base resource. This prevents modifications to the subresource from persisting in the system.
Persisted instances will use the identify
subresource, otherwise the base resource is used.
63 64 65 |
# File 'lib/cardiac/model/declarations.rb', line 63 def base_resource Subresource.new persisted? ? self.class.identify(self) : self.class.base_resource end |