class Ey::Core::Client::AutoScalingPolicies

Constants

MODELS_TO_TYPE

Public Instance Methods

new(attributes = {}) click to toggle source
# File lib/ey-core/collections/auto_scaling_policies.rb, line 15
def new(attributes = {})
  unless attributes.is_a?(::Hash)
    raise(ArgumentError.new("Initialization parameters must be an attributes hash, got #{attributes.class} #{attributes.inspect}"))
  end

  params = Cistern::Hash.stringify_keys(attributes)
  type = params["type"] ||= "simple"
  model = MODELS_TO_TYPE[type]
  unless model
    raise(ArgumentError.new("Unrecognized policy type #{type}. Allowed types are: #{MODELS_TO_TYPE.keys.join(', ')}"))
  end
  model.new(
    {
      :collection => self,
      :connection => connection,
    }.merge(params)
  )
end