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.



6705
6706
6707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6705

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



6703
6704
6705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6703

def value
  @value
end

Class Method Details

.ALLObject



6725
6726
6727
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6725

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



6710
6711
6712
6713
6714
6715
6716
6717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6710

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



6730
6731
6732
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6730

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



6720
6721
6722
6723
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6720

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



6735
6736
6737
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6735

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

Instance Method Details

#to_hashObject



6739
6740
6741
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6739

def to_hash
  value
end