Module: SparkApi::Models::Defaultable::ClassMethods

Defined in:
lib/spark_api/models/defaultable.rb

Instance Method Summary collapse

Instance Method Details

#default(options = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/spark_api/models/defaultable.rb', line 21

def default(options = {})
  response = connection.get("/#{element_name}/default", options).first
  unless response.nil?
    response["Id"] = DEFAULT_ID if response["Id"].nil?
    new(response)
  end
end

#find(*arguments) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/spark_api/models/defaultable.rb', line 29

def find(*arguments)
  if arguments.first == DEFAULT_ID
    options = arguments.slice!(1) || {}
    default(options)
  else
    original_find(*arguments)
  end
end