Class: Spree::AgentTools::ResourceWrite
- Inherits:
-
Spree::AgentTool
- Object
- Spree::AgentTool
- Spree::AgentTools::ResourceWrite
- Defined in:
- app/tools/spree/agent_tools/resource_write.rb
Overview
Shared by the generic writes, which dispatch to the Admin API's own create, update and destroy operations.
The controller behind each decides everything that matters: which attributes it accepts, whether it writes through a workflow, what the refusal reads like. So these three are correct for every resource, and the rule that a resource with a workflow refuses the generic write is gone — there was only ever one way to write a record, and now these take it.
Direct Known Subclasses
Constant Summary
Constants inherited from Spree::AgentTool
Spree::AgentTool::PARENT_ID_DESCRIPTION
Instance Attribute Summary
Attributes inherited from Spree::AgentTool
Instance Method Summary collapse
-
#permitted? ⇒ Boolean
Offered only to a caller who can write something.
Methods inherited from Spree::AgentTool
additive!, audience, #call, description, destructive?, #initialize, input_schema, mutating!, mutating?, param, params, permission, #summary, tool_name, #unknown_resource
Constructor Details
This class inherits a constructor from Spree::AgentTool
Instance Method Details
#permitted? ⇒ Boolean
Offered only to a caller who can write something.
The endpoint would refuse anyway, but a tool a credential can never use should not be named to the model: the server promises that a tool you cannot see is one the store has not granted.
23 24 25 26 27 |
# File 'app/tools/spree/agent_tools/resource_write.rb', line 23 def permitted? ResourceMap.all.any? do |entry| entry..present? && context.permitted?(entry.) end end |