Module: Supplejack::Concept::ClassMethods

Defined in:
lib/supplejack/concept.rb

Instance Method Summary collapse

Instance Method Details

#find(id, options = {}) ⇒ Supplejack::Concept

Finds a record or array of records from the Supplejack API

Supplejack::Concept module was included

Returns:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/supplejack/concept.rb', line 70

def find(id, options={})
  begin
    # handle malformed id's before requesting anything.
    id = id.to_i
    raise(Supplejack::MalformedRequest, "'#{id}' is not a valid concept id") if id <= 0

    # This will not work until the Concepts API supports groups properly
    #options = options.merge({fields: 'default'})

    response = get("/concepts/#{id}", options)
    new(response)
  rescue RestClient::ResourceNotFound => e
    raise Supplejack::ConceptNotFound, "Concept with ID #{id} was not found"
  end
end