Module: Alula::Dcp::StagedValueMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/alula/dcp/staged_value_methods.rb', line 6

def self.included(base)
  base.class_eval do
    class << self
      attr_writer :has_svm

      def has_svm
        @has_svm ||= true
      end
    end
  end
end

Instance Method Details

#primitive?(resource) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/alula/dcp/staged_value_methods.rb', line 45

def primitive?(resource)
  resource.class.get_fields[:primitive]
end

#stagedObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/alula/dcp/staged_value_methods.rb', line 18

def staged
  return nil if values['staged'].nil?

  if primitive?(self)
    # define setter method for staged value
    define_singleton_method :staged= do |value|
      values['staged'] = value
    end
    return values['staged']
  end

  @staged ||= StagedState.new(self)
end

#valueObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/alula/dcp/staged_value_methods.rb', line 32

def value
  return nil if values['value'].nil?
  if primitive?(self)
    # define setter method for value
    define_singleton_method :value= do |value|
      values['value'] = value
    end
    return values['value']
  end

  @value ||= ValueState.new(self)
end