Class: Procedo::Engine::Intervention::Output

Inherits:
Quantified show all
Defined in:
lib/procedo/engine/intervention/output.rb

Instance Attribute Summary collapse

Attributes inherited from Quantified

#quantity_handler, #quantity_population, #quantity_value

Attributes inherited from ProductParameter

#assembly, #component, #product, #read_at, #readings, #working_zone

Attributes inherited from Parameter

#group, #id, #intervention, #name, #reference, #type

Instance Method Summary collapse

Methods inherited from Quantified

#compute_population, #compute_value, #handlers_states, #impact_dependencies!, #impact_on_handlers, #quantity_handler_reference

Methods inherited from ProductParameter

#add_reading, #assembly?, #assembly_id, #assembly_id=, #component?, #component_id, #component_id=, #compute_attribute, #compute_reading, #impact_dependencies!, #impact_on_attributes, #impact_on_components, #impact_on_parameters, #impact_on_readings, #impact_with, #product?, #product_id, #product_id=, #read_at?, #reading, #usable_attribute?, #usable_handler?, #usable_reading?, #working_zone?

Methods inherited from Parameter

#dependents, #impact_dependencies!, #impact_with, #param_name, #root?

Methods included from Reassignable

#assign, #assign!, #reassign, #reassign!

Constructor Details

#initialize(intervention, id, attributes = {}) ⇒ Output

Returns a new instance of Output.


11
12
13
14
15
16
17
18
# File 'lib/procedo/engine/intervention/output.rb', line 11

def initialize(intervention, id, attributes = {})
  super(intervention, id, attributes)
  if @attributes[:variant_id].present?
    @variant = ProductNatureVariant.find_by(id: @attributes[:variant_id])
  end
  @new_name = @attributes[:new_name]
  @identification_number = @attributes[:identification_number]
end

Instance Attribute Details

#identification_numberObject

Returns the value of attribute identification_number


9
10
11
# File 'lib/procedo/engine/intervention/output.rb', line 9

def identification_number
  @identification_number
end

#new_nameObject

Returns the value of attribute new_name


9
10
11
# File 'lib/procedo/engine/intervention/output.rb', line 9

def new_name
  @new_name
end

#variantObject

Returns the value of attribute variant


7
8
9
# File 'lib/procedo/engine/intervention/output.rb', line 7

def variant
  @variant
end

Instance Method Details

#envObject


59
60
61
# File 'lib/procedo/engine/intervention/output.rb', line 59

def env
  super.merge(variant: variant, new_name: new_name, identification_number: identification_number)
end

#to_attributesObject


51
52
53
54
55
56
57
# File 'lib/procedo/engine/intervention/output.rb', line 51

def to_attributes
  hash = super
  hash[:variant_id] = @variant.id if @variant
  hash[:new_name] = @new_name if @new_name.present?
  hash[:identification_number] = @identification_number if @identification_number.present?
  hash
end

#to_hashObject


43
44
45
46
47
48
49
# File 'lib/procedo/engine/intervention/output.rb', line 43

def to_hash
  hash = super
  hash[:variant_id] = @variant.id if @variant
  hash[:new_name] = @new_name if @new_name.present?
  hash[:identification_number] = @identification_number if @identification_number.present?
  hash
end

#variant_idObject


20
21
22
# File 'lib/procedo/engine/intervention/output.rb', line 20

def variant_id
  @variant ? @variant.id : nil
end

#variant_id=(id) ⇒ Object


28
29
30
31
# File 'lib/procedo/engine/intervention/output.rb', line 28

def variant_id=(id)
  @variant = ProductNatureVariant.find_by(id: id)
  impact_dependencies!(:variant)
end