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.



24259
24260
24261
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24259

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



24257
24258
24259
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24257

def value
  @value
end

Class Method Details

.ALLObject



24279
24280
24281
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24279

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



24264
24265
24266
24267
24268
24269
24270
24271
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24264

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



24284
24285
24286
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24284

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



24274
24275
24276
24277
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24274

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



24289
24290
24291
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24289

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

Instance Method Details

#to_hashObject



24293
24294
24295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24293

def to_hash
  value
end