dkastner-moneta 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,53 +5,55 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  module Moneta
8
- class ActiveRecord
9
- include Moneta::Defaults
10
-
11
- def initialize(options = {})
12
- @options = options
13
- unless self.class.const_defined?('Store')
14
- self.class.const_set('Store', Class.new(::ActiveRecord::Base)) # this prevents loading issues when active_record gem is unavailable
8
+ module Adapters
9
+ class ActiveRecord
10
+ include Moneta::Defaults
11
+
12
+ def initialize(options = {})
13
+ @options = options
14
+ unless self.class.const_defined?('Store')
15
+ self.class.const_set('Store', Class.new(::ActiveRecord::Base)) # this prevents loading issues when active_record gem is unavailable
16
+ end
17
+ Store.establish_connection(@options[:connection] || raise("Must specify :connection"))
18
+ Store.set_table_name(@options[:table] || 'moneta_store')
15
19
  end
16
- Store.establish_connection(@options[:connection] || raise("Must specify :connection"))
17
- Store.set_table_name(@options[:table] || 'moneta_store')
18
- end
19
20
 
20
- def migrate
21
- unless Store.table_exists?
22
- Store.connection.create_table Store.table_name, :id => false do |t|
23
- t.string 'key', :primary => :true
24
- t.string 'value'
21
+ def migrate
22
+ unless Store.table_exists?
23
+ Store.connection.create_table Store.table_name, :id => false do |t|
24
+ t.string 'key', :primary => :true
25
+ t.string 'value'
26
+ end
25
27
  end
26
28
  end
27
- end
28
29
 
29
- def key?(key)
30
- record = Store.find_by_key key_for(key)
31
- !record.nil?
32
- end
30
+ def key?(key)
31
+ record = Store.find_by_key key_for(key)
32
+ !record.nil?
33
+ end
33
34
 
34
- def [](key)
35
- record = Store.find_by_key key_for(key)
36
- record ? deserialize(record.value) : nil
37
- end
35
+ def [](key)
36
+ record = Store.find_by_key key_for(key)
37
+ record ? deserialize(record.value) : nil
38
+ end
38
39
 
39
- def delete(key)
40
- record = Store.find_by_key key_for(key)
41
- if record
42
- Store.where(:key => key_for(record.key)).delete_all
43
- deserialize record.value
40
+ def delete(key)
41
+ record = Store.find_by_key key_for(key)
42
+ if record
43
+ Store.where(:key => key_for(record.key)).delete_all
44
+ deserialize record.value
45
+ end
44
46
  end
45
- end
46
47
 
47
- def store(key, value, options = {})
48
- record = Store.new :key => key_for(key), :value => serialize(value)
49
- record.save!
50
- value
51
- end
48
+ def store(key, value, options = {})
49
+ record = Store.new :key => key_for(key), :value => serialize(value)
50
+ record.save!
51
+ value
52
+ end
52
53
 
53
- def clear
54
- Store.delete_all
54
+ def clear
55
+ Store.delete_all
56
+ end
55
57
  end
56
58
  end
57
59
  end
@@ -1,3 +1,3 @@
1
1
  module Moneta
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -5,7 +5,7 @@ require 'moneta/adapters/active_record'
5
5
  if defined?(ActiveRecord)
6
6
  describe 'Moneta::ActiveRecord' do
7
7
  before(:each) do
8
- @cache = Moneta::ActiveRecord.new(:connection => {
8
+ @cache = Moneta::Adapters::ActiveRecord.new(:connection => {
9
9
  :adapter => 'sqlite3',
10
10
  :database => 'reports_test.sqlite3'
11
11
  })
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 0
9
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Yehuda Katz
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- hash: -1558155670169839568
139
+ hash: -3802511716438480578
140
140
  segments:
141
141
  - 0
142
142
  version: "0"
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
- hash: -1558155670169839568
148
+ hash: -3802511716438480578
149
149
  segments:
150
150
  - 0
151
151
  version: "0"