File: ohm_models.rb

package info (click to toggle)
ruby-database-cleaner 1.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 768 kB
  • sloc: ruby: 4,854; makefile: 10; sh: 4
file content (43 lines) | stat: -rw-r--r-- 736 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'ohm'

Ohm.connect :url => ENV['REDIS_URL']

class OhmWidget < Ohm::Model
  attribute :name

  def self.create!(attrs = {})
    new({:name => 'some widget'}.merge(attrs)).save
  end

  def self.count
    all.count
  end

end

class OhmWidgetUsingDatabaseOne < Ohm::Model
  connect :url => ENV['REDIS_URL_ONE']
  attribute :name

  def self.create!(attrs = {})
    new({:name => 'a widget using database one'}.merge(attrs)).save
  end

  def self.count
    all.count
  end

end

class OhmWidgetUsingDatabaseTwo < Ohm::Model
  connect :url => ENV['REDIS_URL_TWO']
  attribute :name

  def self.create!(attrs = {})
    new({:name => 'a widget using database two'}.merge(attrs)).save
  end

  def self.count
    all.count
  end
end