Class: Procedo::Procedure::Parameter

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

Overview

Parameter class is the base class for all parameters types

Direct Known Subclasses

GroupParameter, ProductParameter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(procedure, name, options = {}) ⇒ Parameter

Returns a new instance of Parameter.


12
13
14
15
16
17
# File 'lib/procedo/procedure/parameter.rb', line 12

def initialize(procedure, name, options = {})
  @procedure = procedure
  @name = name.to_sym
  @group = options[:group]
  @cardinality = Procedo::Cardinality.new(options[:cardinality] || '+')
end

Instance Attribute Details

#cardinalityObject

Returns the value of attribute cardinality


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

def cardinality
  @cardinality
end

#groupObject (readonly)

Returns the value of attribute group


7
8
9
# File 'lib/procedo/procedure/parameter.rb', line 7

def group
  @group
end

#nameObject

Returns the value of attribute name


7
8
9
# File 'lib/procedo/procedure/parameter.rb', line 7

def name
  @name
end

#procedureObject (readonly)

Returns the value of attribute procedure


7
8
9
# File 'lib/procedo/procedure/parameter.rb', line 7

def procedure
  @procedure
end

Class Method Details

.typeObject


29
30
31
# File 'lib/procedo/procedure/parameter.rb', line 29

def self.type
  @type ||= name.demodulize.underscore
end

Instance Method Details

#depend_on?(_parameter) ⇒ Boolean

Returns true if self depend on given parameter through a formula of handlers, attributes or readings.

Returns:

  • (Boolean)

51
52
53
# File 'lib/procedo/procedure/parameter.rb', line 51

def depend_on?(_parameter)
  false
end

#human_name(options = {}) ⇒ Object

Translate the name of the parameter


25
26
27
# File 'lib/procedo/procedure/parameter.rb', line 25

def human_name(options = {})
  "procedure_parameters.#{name}".t(options.merge(default: ["labels.#{name}".to_sym, "attributes.#{name}".to_sym, name.to_s.humanize]))
end

#inspectObject


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

def inspect
  "<#{self.class.name} #{procedure_name}##{name}>"
end

#positionObject


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

def position
  procedure.position_of(self)
end

#reflection_nameObject


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

def reflection_name
  self.class.type.pluralize
end

#typeObject


33
34
35
# File 'lib/procedo/procedure/parameter.rb', line 33

def type
  self.class.type
end