Class: Loveseat::Model

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

Direct Known Subclasses

ViewSet

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject



26
27
28
# File 'lib/loveseat/model.rb', line 26

def self.all
  Document.all(self.database, self)
end

.connection=(connection_hash) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/loveseat/model.rb', line 3

def self.connection=(connection_hash)
  @@server = Rest::Server.new(connection_hash[:host],
                            connection_hash[:port],
                            connection_hash[:user],
                            connection_hash[:password])
  @@database = Rest::Database.new(@@server, connection_hash[:database])
end

.databaseObject



38
39
40
# File 'lib/loveseat/model.rb', line 38

def self.database
  @@database
end

.get(id) ⇒ Object



19
20
21
22
23
24
# File 'lib/loveseat/model.rb', line 19

def self.get(id)
  unless id[self.name]
    id = [self.name, id].join(':')
  end
  Document.get(self.database, id)
end

.serverObject



34
35
36
# File 'lib/loveseat/model.rb', line 34

def self.server
  @@server
end

.setup(options = {}, &block) ⇒ Object



30
31
32
# File 'lib/loveseat/model.rb', line 30

def self.setup(options = {}, &block)
  Document.setup(self, options, &block)
end

Instance Method Details

#deleteObject



15
16
17
# File 'lib/loveseat/model.rb', line 15

def delete
  Document.delete(self.class.database, self)
end

#putObject



11
12
13
# File 'lib/loveseat/model.rb', line 11

def put
  Document.put(self.class.database, self)
end