Class: Procedo::Procedure::Setter

Inherits:
Field
  • Object
show all
Defined in:
lib/procedo/procedure/setter.rb

Overview

An Attribute defines an information to complete

Direct Known Subclasses

Attribute, Reading

Instance Attribute Summary collapse

Attributes inherited from Field

#name, #parameter

Instance Method Summary collapse

Constructor Details

#initialize(parameter, name, options = {}) ⇒ Setter

Returns a new instance of Setter.


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/procedo/procedure/setter.rb', line 12

def initialize(parameter, name, options = {})
  super(parameter, name, options)
  @hidden = !!options[:hidden]
  self.default_value = options[:default_value]
  self.condition = options[:if]

  if options[:compute_filter]
    self.compute_filter = options[:compute_filter]
  end
  @filter = options[:filter]

  @computations = []
end

Instance Attribute Details

#computationsObject (readonly)

Returns the value of attribute computations


9
10
11
# File 'lib/procedo/procedure/setter.rb', line 9

def computations
  @computations
end

#computed_filterObject

Returns the value of attribute computed_filter


10
11
12
# File 'lib/procedo/procedure/setter.rb', line 10

def computed_filter
  @computed_filter
end

#filterObject

Returns the value of attribute filter


10
11
12
# File 'lib/procedo/procedure/setter.rb', line 10

def filter
  @filter
end

Instance Method Details

#accessible?Boolean

Returns true if setter can be accessed by a human during recording process.

Returns:

  • (Boolean)

28
29
30
# File 'lib/procedo/procedure/setter.rb', line 28

def accessible?
  !@hidden
end

#add_computation(expression, destinations, options = {}) ⇒ Object


41
42
43
# File 'lib/procedo/procedure/setter.rb', line 41

def add_computation(expression, destinations, options = {})
  @computations << Procedo::Procedure::Computation.new(@parameter, expression, options.merge(expression: expression, destinations: destinations))
end

#depend_on?(parameter_name) ⇒ Boolean

Returns:

  • (Boolean)

36
37
38
39
# File 'lib/procedo/procedure/setter.rb', line 36

def depend_on?(parameter_name)
  default_value_with_parameter?(parameter_name) ||
    condition_with_parameter?(parameter_name)
end

#hidden?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/procedo/procedure/setter.rb', line 32

def hidden?
  @hidden
end

#scope_hashObject

Returns scope hash for unroll


46
47
48
49
50
51
# File 'lib/procedo/procedure/setter.rb', line 46

def scope_hash
  hash = {}
  hash[:of_expression] = @filter unless @filter.nil?
  hash[:of_expression] = @computed_filter unless @computed_filter.nil?
  hash
end