Class: Request::ChangeDecision

Inherits:
Object
  • Object
show all
Includes:
Validateable
Defined in:
app/models/request/change_decision.rb

Overview

rubocop:todo Style/Documentation

Defined Under Namespace

Classes: ChangeDecisionError

Constant Summary collapse

InvalidDecision =
Class.new(ChangeDecisionError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validateable

append_features, #method_missing, #validate!

Constructor Details

#initialize(attributes) ⇒ ChangeDecision

Returns a new instance of ChangeDecision.


39
40
41
# File 'app/models/request/change_decision.rb', line 39

def initialize(attributes)
  attributes.each { |k, v| send(:"#{k}=", v) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Validateable

Instance Attribute Details

#asset_qc_stateObject

Returns the value of attribute asset_qc_state.


15
16
17
# File 'app/models/request/change_decision.rb', line 15

def asset_qc_state
  @asset_qc_state
end

#asset_qc_state_check_boxObject

Returns the value of attribute asset_qc_state_check_box.


15
16
17
# File 'app/models/request/change_decision.rb', line 15

def asset_qc_state_check_box
  @asset_qc_state_check_box
end

#change_decision_check_boxObject

Returns the value of attribute change_decision_check_box.


15
16
17
# File 'app/models/request/change_decision.rb', line 15

def change_decision_check_box
  @change_decision_check_box
end

#commentObject

Returns the value of attribute comment.


15
16
17
# File 'app/models/request/change_decision.rb', line 15

def comment
  @comment
end

#requestObject

Returns the value of attribute request.


15
16
17
# File 'app/models/request/change_decision.rb', line 15

def request
  @request
end

#userObject

Returns the value of attribute user.


15
16
17
# File 'app/models/request/change_decision.rb', line 15

def user
  @user
end

Instance Method Details

#asset_qc_state_absent?Boolean

Returns:

  • (Boolean)

47
48
49
# File 'app/models/request/change_decision.rb', line 47

def asset_qc_state_absent?
  asset_qc_state_check_box == '0' || asset_qc_state_check_box.nil?
end

#checkboxesObject


17
18
19
# File 'app/models/request/change_decision.rb', line 17

def checkboxes
  [change_decision_check_box, asset_qc_state_check_box]
end

#execute!Object

Raises:


51
52
53
54
55
# File 'app/models/request/change_decision.rb', line 51

def execute!
  raise InvalidDecision, self unless valid?

  perform_decision_change!
end

#state_change?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'app/models/request/change_decision.rb', line 43

def state_change?
  change_decision_check_box == '1'
end