Class: OrientDB::AR::Query
- Inherits:
-
Object
- Object
- OrientDB::AR::Query
- Defined in:
- lib/model/base.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#query ⇒ Object
Returns the value of attribute query.
Instance Method Summary collapse
- #all ⇒ Object
- #first ⇒ Object
-
#initialize(model, query = OrientDB::SQL::Query.new) ⇒ Query
constructor
A new instance of Query.
- #inspect ⇒ Object (also: #to_s)
- #results ⇒ Object
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
#model ⇒ Object
Returns the value of attribute model.
216 217 218 |
# File 'lib/model/base.rb', line 216 def model @model end |
#query ⇒ Object
Returns the value of attribute query.
216 217 218 |
# File 'lib/model/base.rb', line 216 def query @query end |
Instance Method Details
#all ⇒ Object
230 231 232 |
# File 'lib/model/base.rb', line 230 def all model.connection.query(query).map { |doc| model.new_from_doc doc } end |
#first ⇒ Object
234 235 236 |
# File 'lib/model/base.rb', line 234 def first model.new_from_doc model.connection.first(query) end |
#inspect ⇒ Object 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 |
#results ⇒ Object
238 239 240 |
# File 'lib/model/base.rb', line 238 def results model.connection.query(query).map end |