Class: Squongo::Document
- Inherits:
-
Object
- Object
- Squongo::Document
- Defined in:
- lib/squongo/document.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data: {}) ⇒ Document
constructor
A new instance of Document.
- #save ⇒ Object
- #table ⇒ Object
Constructor Details
#initialize(data: {}) ⇒ Document
Returns a new instance of Document.
4 5 6 |
# File 'lib/squongo/document.rb', line 4 def initialize(data: {}) @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/squongo/document.rb', line 2 def data @data end |
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/squongo/document.rb', line 20 def self.all Squongo.connection.db.execute "SELECT * FROM #{table}" end |
.first ⇒ Object
12 13 14 |
# File 'lib/squongo/document.rb', line 12 def self.first Squongo.connection.db.execute "SELECT * FROM #{table} ORDER BY id LIMIT 1" end |
.last ⇒ Object
16 17 18 |
# File 'lib/squongo/document.rb', line 16 def self.last Squongo.connection.db.execute "SELECT * FROM #{table} ORDER BY id DESC LIMIT 1" end |
.table ⇒ Object
28 29 30 |
# File 'lib/squongo/document.rb', line 28 def self.table self.const_get :TABLE end |