Class: Nayati::MasterOperation
- Inherits:
-
Object
- Object
- Nayati::MasterOperation
- Defined in:
- app/models/nayati/master_operation.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #edit(new_name) ⇒ Object
- #edit_error_message ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(master_workflow, operation_name) ⇒ MasterOperation
constructor
A new instance of MasterOperation.
- #save ⇒ Object
- #update ⇒ Object
- #valid_edit? ⇒ Boolean
Constructor Details
#initialize(master_workflow, operation_name) ⇒ MasterOperation
Returns a new instance of MasterOperation.
4 5 6 7 8 |
# File 'app/models/nayati/master_operation.rb', line 4 def initialize(master_workflow, operation_name) @master_workflow = master_workflow @name = operation_name @edit_errors = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'app/models/nayati/master_operation.rb', line 3 def name @name end |
Instance Method Details
#edit(new_name) ⇒ Object
10 11 12 13 14 |
# File 'app/models/nayati/master_operation.rb', line 10 def edit(new_name) @new_name = ::Nayati::NameBasedConstantable.name_as_namespace(new_name.to_s) @is_name_changed = true unless @new_name == @name @valid_edit_called = false end |
#edit_error_message ⇒ Object
35 36 37 |
# File 'app/models/nayati/master_operation.rb', line 35 def @edit_errors.join(', ') end |
#exists? ⇒ Boolean
16 17 18 |
# File 'app/models/nayati/master_operation.rb', line 16 def exists? @master_workflow.operation_names.include?(@name) end |
#save ⇒ Object
20 21 22 |
# File 'app/models/nayati/master_operation.rb', line 20 def save OperationConfiguration.add_operation_unless_present(@master_workflow.name, @name) end |
#update ⇒ Object
30 31 32 33 |
# File 'app/models/nayati/master_operation.rb', line 30 def update raise 'Please check valid edit first' unless @valid_edit_called OperationConfiguration.update_operation(@master_workflow.name, @name, @new_name) end |
#valid_edit? ⇒ Boolean
24 25 26 27 28 |
# File 'app/models/nayati/master_operation.rb', line 24 def valid_edit? validate_name_for_edit if @is_name_changed @edit_errors.empty? @valid_edit_called = true end |