Class: Procedo::Engine::Intervention::Parameter

Inherits:
Object
  • Object
show all
Includes:
Reassignable
Defined in:
lib/procedo/engine/intervention/parameter.rb

Direct Known Subclasses

GroupParameter, ProductParameter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Reassignable

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

Constructor Details

#initialize(group, id, attributes = {}) ⇒ Parameter

Returns a new instance of Parameter.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/procedo/engine/intervention/parameter.rb', line 14

def initialize(group, id, attributes = {})
  if group.is_a?(Procedo::Engine::Intervention)
    @intervention = group
  elsif group.is_a?(Procedo::Engine::Intervention::GroupParameter)
    @group = group
    @intervention = @group.intervention
  else
    raise "Invalid group: #{group.inspect}"
  end
  @attributes = attributes.symbolize_keys
  @id = id.to_s
  unless root?
    @name = @attributes[:reference_name].to_sym
    @reference = procedure.find!(@name)
    @type = @reference.type
  end
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group


8
9
10
# File 'lib/procedo/engine/intervention/parameter.rb', line 8

def group
  @group
end

#idObject (readonly)

Returns the value of attribute id


8
9
10
# File 'lib/procedo/engine/intervention/parameter.rb', line 8

def id
  @id
end

#interventionObject (readonly)

Returns the value of attribute intervention


8
9
10
# File 'lib/procedo/engine/intervention/parameter.rb', line 8

def intervention
  @intervention
end

#nameObject (readonly)

Returns the value of attribute name


8
9
10
# File 'lib/procedo/engine/intervention/parameter.rb', line 8

def name
  @name
end

#referenceObject (readonly)

Returns the value of attribute reference


8
9
10
# File 'lib/procedo/engine/intervention/parameter.rb', line 8

def reference
  @reference
end

#typeObject (readonly)

Returns the value of attribute type


8
9
10
# File 'lib/procedo/engine/intervention/parameter.rb', line 8

def type
  @type
end

Instance Method Details

#dependentsObject


53
54
55
# File 'lib/procedo/engine/intervention/parameter.rb', line 53

def dependents
  procedure.parameters.select { |p| p.depend_on?(reference.name) }
end

#envObject


57
58
59
# File 'lib/procedo/engine/intervention/parameter.rb', line 57

def env
  { self: self }
end

#impact_dependencies!(field = nil) ⇒ Object


49
50
51
# File 'lib/procedo/engine/intervention/parameter.rb', line 49

def impact_dependencies!(field = nil)
  # Nothing to do at this level except detect and refresh dependent parameters
end

#impact_with(_steps) ⇒ Object

Raises:

  • (NotImplementedError)

45
46
47
# File 'lib/procedo/engine/intervention/parameter.rb', line 45

def impact_with(_steps)
  raise NotImplementedError
end

#param_nameObject


41
42
43
# File 'lib/procedo/engine/intervention/parameter.rb', line 41

def param_name
  "#{type.to_s.pluralize}_attributes".to_sym
end

#root?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/procedo/engine/intervention/parameter.rb', line 32

def root?
  @id == Procedo::Procedure::ROOT_NAME
end

#to_hashObject Also known as: to_attributes


36
37
38
# File 'lib/procedo/engine/intervention/parameter.rb', line 36

def to_hash
  { reference_name: @reference.name }
end