Class: Io::Flow::V0::Models::TierStrategy

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) ⇒ TierStrategy

Returns a new instance of TierStrategy.



27674
27675
27676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27674

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



27672
27673
27674
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27672

def value
  @value
end

Class Method Details

.ALLObject



27694
27695
27696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27694

def TierStrategy.ALL
  @@all ||= [TierStrategy.fastest, TierStrategy.lowest_cost]
end

.apply(value) ⇒ Object

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



27679
27680
27681
27682
27683
27684
27685
27686
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27679

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

.fastestObject

Optimize for fastest first, then cheapest



27699
27700
27701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27699

def TierStrategy.fastest
  @@_fastest ||= TierStrategy.new('fastest')
end

.from_string(value) ⇒ Object

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



27689
27690
27691
27692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27689

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

.lowest_costObject

Optimize for lowest cost first, then fastest



27704
27705
27706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27704

def TierStrategy.lowest_cost
  @@_lowest_cost ||= TierStrategy.new('lowest_cost')
end

Instance Method Details

#to_hashObject



27708
27709
27710
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27708

def to_hash
  value
end