Class: OrientDB::AR::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/model/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, query = OrientDB::SQL::Query.new) ⇒ Query

Returns a new instance of Query.



218
219
220
221
# File 'lib/model/base.rb', line 218

def initialize(model, query = OrientDB::SQL::Query.new)
  @model, @query = model, query
  @query.from model.name
end

Instance Attribute Details

#modelObject

Returns the value of attribute model.



216
217
218
# File 'lib/model/base.rb', line 216

def model
  @model
end

#queryObject

Returns the value of attribute query.



216
217
218
# File 'lib/model/base.rb', line 216

def query
  @query
end

Instance Method Details

#allObject



230
231
232
# File 'lib/model/base.rb', line 230

def all
  model.connection.query(query).map { |doc| model.new_from_doc doc }
end

#firstObject



234
235
236
# File 'lib/model/base.rb', line 234

def first
  model.new_from_doc model.connection.first(query)
end

#inspectObject Also known as: to_s



242
243
244
# File 'lib/model/base.rb', line 242

def inspect
  %{#<OrientDB::AR::Query:#{model.name} query="#{query.to_s}">}
end

#resultsObject



238
239
240
# File 'lib/model/base.rb', line 238

def results
  model.connection.query(query).map
end