Method: Rubyists::Linear::BaseModel::ClassMethods#find

Defined in:
lib/linear/models/base_model/class_methods.rb

#find(id_val) ⇒ Object

Raises:



53
54
55
56
57
58
59
60
61
# File 'lib/linear/models/base_model/class_methods.rb', line 53

def find(id_val)
  camel_name = just_name.camelize :lower
  sym = camel_name.to_sym
  ff = full_fragment
  query_data = Api.query(query { __node(camel_name, id: id_val) { ___ ff } })
  raise NotFoundError, "No #{just_name} found with id #{id_val}" if query_data.nil? || query_data[sym].nil?

  new query_data[sym]
end