Class: DesignManagement::DesignAction
- Inherits:
-
Object
- Object
- DesignManagement::DesignAction
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/design_management/design_action.rb
Overview
Parameter object which is a tuple of the database record and the last gitaly call made to change it. This serves to perform the logical mapping from git action to database representation.
Constant Summary collapse
- EVENT_FOR_GITALY_ACTION =
{ create: DesignManagement::Action.events[:creation], update: DesignManagement::Action.events[:modification], delete: DesignManagement::Action.events[:deletion] }.freeze
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#design ⇒ Object
readonly
Returns the value of attribute design.
Instance Method Summary collapse
- #gitaly_action ⇒ Object
-
#initialize(design, action, content = nil) ⇒ DesignAction
constructor
Parameters: - design [DesignManagement::Design]: the design that was changed - action [Symbol]: the action that gitaly performed.
-
#performed ⇒ Object
This action has been performed - do any post-creation actions such as clearing method caches.
- #row_attrs(version) ⇒ Object
Constructor Details
#initialize(design, action, content = nil) ⇒ DesignAction
Parameters:
-
design [DesignManagement::Design]: the design that was changed
-
action [Symbol]: the action that gitaly performed
31 32 33 34 35 36 |
# File 'app/models/design_management/design_action.rb', line 31 def initialize(design, action, content = nil) @design = design @action = action @content = content validate! end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
16 17 18 |
# File 'app/models/design_management/design_action.rb', line 16 def action @action end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
16 17 18 |
# File 'app/models/design_management/design_action.rb', line 16 def content @content end |
#design ⇒ Object (readonly)
Returns the value of attribute design.
16 17 18 |
# File 'app/models/design_management/design_action.rb', line 16 def design @design end |
Instance Method Details
#gitaly_action ⇒ Object
42 43 44 |
# File 'app/models/design_management/design_action.rb', line 42 def gitaly_action { action: action, file_path: design.full_path, content: content }.compact end |
#performed ⇒ Object
This action has been performed - do any post-creation actions such as clearing method caches.
48 49 50 |
# File 'app/models/design_management/design_action.rb', line 48 def performed design.clear_version_cache end |
#row_attrs(version) ⇒ Object
38 39 40 |
# File 'app/models/design_management/design_action.rb', line 38 def row_attrs(version) { design_id: design.id, version_id: version.id, event: event } end |