Class: Shamu::Auditing::Transaction
- Inherits:
-
Services::Request
- Object
- Services::Request
- Shamu::Auditing::Transaction
- Includes:
- Entities::EntityPath
- Defined in:
- lib/shamu/auditing/transaction.rb
Overview
An audit record of a discrete change transaction.
Constant Summary
Constants inherited from Services::Request
Services::Request::REQUEST_ACTION_PATTERN
Attributes collapse
-
#action ⇒ String
The primitive action that was requested, such as
add
,remove
, orchange
. -
#changes ⇒ Hash
The changes by attribute requested in the transaction.
-
#user_id_chain ⇒ Array<Object>
Security::Principal in place at the time of the request.
Instance Method Summary collapse
-
#append_entity(entity) ⇒ Object
Appends a child node to the #entity_path.
-
#apply_to(model) ⇒ model
Applies the attributes of the request to the given model.
-
#entities? ⇒ Boolean
True if entities have been added to the transaction.
Methods included from Entities::EntityPath
#compose_entity_path, #decompose_entity_path
Methods inherited from Services::Request
coerce, coerce!, #complete, model_name, #on_complete, #on_fail, #on_success, #persisted?
Methods included from Shamu::Attributes::Validation
attribute, #valid?, #validated?
Methods included from Shamu::Attributes::Assignment
#[]=, #assigned?, #assigned_attributes, attribute, #unassigned_attributes
Methods included from Shamu::Attributes
#[], #assign_attributes, association, associations, attribute, #attribute?, attributes, #initialize, #set?, #slice, #to_attributes
Instance Attribute Details
#action ⇒ String
Returns the primitive action that was requested, such as add
,
remove
, or change
.
20 |
# File 'lib/shamu/auditing/transaction.rb', line 20 attribute :action, presence: true |
#changes ⇒ Hash
Returns the changes by attribute requested in the transaction.
24 |
# File 'lib/shamu/auditing/transaction.rb', line 24 attribute :changes |
#user_id_chain ⇒ Array<Object>
Security::Principal in place at the time of the request.
15 |
# File 'lib/shamu/auditing/transaction.rb', line 15 attribute :user_id_chain, presence: true |
Instance Method Details
#append_entity(entity) ⇒ Object #append_entity(pair) ⇒ Object
Appends a child node to the #entity_path.
40 41 42 43 |
# File 'lib/shamu/auditing/transaction.rb', line 40 def append_entity( entity ) @entities ||= [] entities << entity end |
#apply_to(model) ⇒ model
Applies the attributes of the request to the given model. Only handles scalar attributes. For more complex associations, override in a custom Request class.
46 47 48 49 50 |
# File 'lib/shamu/auditing/transaction.rb', line 46 def apply_to( model ) super.tap do assign_changes_to_model model end end |
#entities? ⇒ Boolean
Returns true if entities have been added to the transaction.
53 54 55 |
# File 'lib/shamu/auditing/transaction.rb', line 53 def entities? entities.present? end |