Class: Request::ChangeDecision

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

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


41
42
43
# File 'app/models/request/change_decision.rb', line 41

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


23
24
25
# File 'app/models/request/change_decision.rb', line 23

def asset_qc_state
  @asset_qc_state
end

#asset_qc_state_check_boxObject

Returns the value of attribute asset_qc_state_check_box


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

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


13
14
15
# File 'app/models/request/change_decision.rb', line 13

def change_decision_check_box
  @change_decision_check_box
end

#commentObject

Returns the value of attribute comment


33
34
35
# File 'app/models/request/change_decision.rb', line 33

def comment
  @comment
end

#requestObject

Returns the value of attribute request


36
37
38
# File 'app/models/request/change_decision.rb', line 36

def request
  @request
end

#userObject

Returns the value of attribute user


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

def user
  @user
end

Instance Method Details

#asset_qc_state_absent?Boolean

Returns:

  • (Boolean)

49
50
51
# File 'app/models/request/change_decision.rb', line 49

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

#checkboxesObject


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

def checkboxes
  [change_decision_check_box, asset_qc_state_check_box]
end

#execute!Object

Raises:


53
54
55
56
57
# File 'app/models/request/change_decision.rb', line 53

def execute!
  raise InvalidDecision, self unless valid?

  perform_decision_change!
end

#state_change?Boolean

Returns:

  • (Boolean)

45
46
47
# File 'app/models/request/change_decision.rb', line 45

def state_change?
  change_decision_check_box == '1'
end