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.



9864
9865
9866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9864

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



9862
9863
9864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9862

def value
  @value
end

Class Method Details

.ALLObject



9884
9885
9886
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9884

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



9869
9870
9871
9872
9873
9874
9875
9876
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9869

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



9889
9890
9891
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9889

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



9879
9880
9881
9882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9879

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



9894
9895
9896
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9894

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

Instance Method Details

#to_hashObject



9898
9899
9900
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9898

def to_hash
  value
end