Class: Conjur::Policy::Executor::CreateRecord
- Includes:
- Annotate
- Defined in:
- lib/conjur/policy/executor/create.rb
Overview
Generic ‘create’ implementation which POSTs to a resources URL.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #annotate_record ⇒ Object
-
#create_parameters ⇒ Object
Each record is assumed to have an ‘id’ attribute required for creation.
- #create_path ⇒ Object
- #execute ⇒ Object
- #kind_path ⇒ Object
Methods included from Annotate
#annotate, #update_annotation_path
Methods inherited from Create
Methods inherited from Base
#action, #initialize, #resource_path, #role_path
Methods included from Logger
Constructor Details
This class inherits a constructor from Conjur::Policy::Executor::Base
Instance Method Details
#annotate_record ⇒ Object
22 23 24 |
# File 'lib/conjur/policy/executor/create.rb', line 22 def annotate_record record end |
#create_parameters ⇒ Object
Each record is assumed to have an ‘id’ attribute required for creation. In addition, other create parameters can be specified by the custom_attribute_names
method on the record.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/conjur/policy/executor/create.rb', line 37 def create_parameters { record.id_attribute => record.id }.tap do |params| custom_attrs = record.custom_attribute_names.inject({}) do |memo, attr| value = record.send(attr) memo[attr.to_s] = value if value memo end params.merge! custom_attrs params["ownerid"] = record.owner.roleid if record.owner end end |
#create_path ⇒ Object
26 27 28 |
# File 'lib/conjur/policy/executor/create.rb', line 26 def create_path [ kind_path ].join('/') end |
#execute ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/conjur/policy/executor/create.rb', line 13 def execute action({ 'method' => 'post', 'path' => create_path, 'parameters' => create_parameters }) annotate end |
#kind_path ⇒ Object
30 31 32 |
# File 'lib/conjur/policy/executor/create.rb', line 30 def kind_path record.resource_kind.pluralize end |