Class: Io::Flow::V0::Models::AttributeDataType

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ AttributeDataType

Returns a new instance of AttributeDataType.



14687
14688
14689
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14687

def initialize(value)
  @value = HttpClient::Preconditions.assert_class('value', value, String)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



14685
14686
14687
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14685

def value
  @value
end

Class Method Details

.ALLObject



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def AttributeDataType.ALL
  @@all ||= [AttributeDataType.boolean, AttributeDataType.integer, AttributeDataType.decimal, AttributeDataType.string, AttributeDataType.json_array]
end

.apply(value) ⇒ Object

Returns the instance of AttributeDataType for this value, creating a new instance for an unknown value



14692
14693
14694
14695
14696
14697
14698
14699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14692

def AttributeDataType.apply(value)
  if value.instance_of?(AttributeDataType)
    value
  else
    HttpClient::Preconditions.assert_class_or_nil('value', value, String)
    value.nil? ? nil : (from_string(value) || AttributeDataType.new(value))
  end
end

.booleanObject

Boolean true/false data type



14712
14713
14714
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14712

def AttributeDataType.boolean
  @@_boolean ||= AttributeDataType.new('boolean')
end

.decimalObject

Decimal datatype without size or precision restrictions. Commonly used for currency values.



14723
14724
14725
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14723

def AttributeDataType.decimal
  @@_decimal ||= AttributeDataType.new('decimal')
end

.from_string(value) ⇒ Object

Returns the instance of AttributeDataType for this value, or nil if not found



14702
14703
14704
14705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14702

def AttributeDataType.from_string(value)
  HttpClient::Preconditions.assert_class('value', value, String)
  AttributeDataType.ALL.find { |v| v.value == value }
end

.integerObject

Value of the attribute must be an integer



14717
14718
14719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14717

def AttributeDataType.integer
  @@_integer ||= AttributeDataType.new('integer')
end

.json_arrayObject

An example [“Cotton”, “Wool”]



14733
14734
14735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14733

def AttributeDataType.json_array
  @@_json_array ||= AttributeDataType.new('json_array')
end

.stringObject

Unvalidated string of characters.



14728
14729
14730
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14728

def AttributeDataType.string
  @@_string ||= AttributeDataType.new('string')
end

Instance Method Details

#to_hashObject



14737
14738
14739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14737

def to_hash
  value
end