Class: Nayati::MasterOperation

Inherits:
Object
  • Object
show all
Defined in:
app/models/nayati/master_operation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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_messageObject



35
36
37
# File 'app/models/nayati/master_operation.rb', line 35

def edit_error_message
  @edit_errors.join(', ')
end

#exists?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/models/nayati/master_operation.rb', line 16

def exists?
  @master_workflow.operation_names.include?(@name)
end

#saveObject



20
21
22
# File 'app/models/nayati/master_operation.rb', line 20

def save
  OperationConfiguration.add_operation_unless_present(@master_workflow.name, @name)
end

#updateObject



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

Returns:

  • (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