Class: DTK::State::ComponentDef::AttributeTypeInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/state/component_def/attribute_type_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params) ⇒ AttributeTypeInfo

Returns a new instance of AttributeTypeInfo.



7
8
9
10
11
12
13
14
# File 'lib/state/component_def/attribute_type_info.rb', line 7

def initialize(name, params)
  @name      = name.to_s
  @type      = params[:type]
  @required  = params[:required]  || false
  @dynamic   = params[:dynamic]   || false
  @temporal  = params[:temporal]  || false
  @encrypted = params[:encrypted] || false
end

Instance Attribute Details

#dynamicObject (readonly)

Returns the value of attribute dynamic.



5
6
7
# File 'lib/state/component_def/attribute_type_info.rb', line 5

def dynamic
  @dynamic
end

#encryptedObject (readonly)

Returns the value of attribute encrypted.



5
6
7
# File 'lib/state/component_def/attribute_type_info.rb', line 5

def encrypted
  @encrypted
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/state/component_def/attribute_type_info.rb', line 5

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required.



5
6
7
# File 'lib/state/component_def/attribute_type_info.rb', line 5

def required
  @required
end

#temporalObject (readonly)

Returns the value of attribute temporal.



5
6
7
# File 'lib/state/component_def/attribute_type_info.rb', line 5

def temporal
  @temporal
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/state/component_def/attribute_type_info.rb', line 5

def type
  @type
end

Class Method Details

.create_from_kube_hash(kube_attributes) ⇒ Object



16
17
18
19
20
# File 'lib/state/component_def/attribute_type_info.rb', line 16

def self.create_from_kube_hash(kube_attributes)
  kube_attributes.to_hash.map do |attribute_name, attribute_content|
    AttributeTypeInfo.new(attribute_name, attribute_content)
  end
end

Instance Method Details

#to_hashObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/state/component_def/attribute_type_info.rb', line 22

def to_hash
  type_info = {}

  type_info.merge!(name: @name) if @name
  type_info.merge!(type: @type) if @type
  type_info.merge!(required: @required) if @required
  type_info.merge!(dynamic: @dynamic) if @dynamic
  type_info.merge!(temporal: @temporal) if @temporal
  type_info.merge!(encrypted: @encrypted) if @encrypted

  type_info
end