store-active_record 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ed03bc3ce06165f5a57e2b101a4615e3b50b37a
4
- data.tar.gz: cafff8805390a11ea7001fd97d232a058aa8650c
3
+ metadata.gz: b7abe63975f357775d815d41143e4f528a280769
4
+ data.tar.gz: b00ea1ffb17681a143da988ce78e12b00faa2f78
5
5
  SHA512:
6
- metadata.gz: f1c02ecc0f6a32ec1ae002e5ec24863e21125de0a8d79dc2c60e5f15ae5f72de8f79b7ebe500ba9254ffd3167e53c399b2681a83c0112bd72701bc09b9bf267d
7
- data.tar.gz: 0dc22af510ea697d1dec8c95672fd25fc6dcdb04787a2e86546701f92bd217ebd87e0e76c41f3a9710223097684949d4c83881de666b0823b389785b125a6ef5
6
+ metadata.gz: 79a510dc34f35d82d56eb613e0dc42efd9271dc1d0e7e749f16b79b351224d0decbae888298ae4dca7fe7c8d3ce5c5f775c29548078fab4d923512ed833280f5
7
+ data.tar.gz: bb5b035a0ff2f45efe7f0fc209ecc78023708f961d0482e922c2ddec1fc0a19b358815fbcc840b248be8ded94c17d4e023378aac85a676f8531e3c10249a7741
data/README.md CHANGED
@@ -47,29 +47,13 @@ end
47
47
 
48
48
  ```
49
49
 
50
- ```
51
- require 'store/active_record'
50
+ Establish connection to the database
52
51
 
53
- module DataMapper
54
- module User
55
- class ActiveRecord < Store::DataMapper::ActiveRecord
56
- end
57
- end
58
- end
59
-
60
- table = 'users'
52
+ ```
53
+ require 'activerecord'
61
54
 
62
- spec = {
63
- :adapter => sqlite3
64
- :encoding => utf8
65
- :collation => utf8_general_ci
66
- :reconnect => false
67
- :database => database_name
68
- }
55
+ spec = YAML.load_file(path_to_your_database_yml)['production']
69
56
 
70
- # or load it from your database.yml
71
- # spec = YAML.load_file(path_to_your_database_yml)['production']
72
- #
73
57
  # database.yml
74
58
  #
75
59
  # development:
@@ -88,7 +72,20 @@ spec = {
88
72
  #
89
73
  # production: development
90
74
 
91
- DataMapper::User::ActiveRecord.new(table, spec)
75
+ ActiveRecord::Base.establish_connection(spec)
76
+ ```
77
+
78
+ ```
79
+ require 'store/active_record'
80
+
81
+ module DataMapper
82
+ module User
83
+ class ActiveRecord < Store::DataMapper::ActiveRecord
84
+ end
85
+ end
86
+ end
87
+
88
+ DataMapper::User::ActiveRecord.new('users')
92
89
  ```
93
90
 
94
91
  ## Tests
@@ -1,15 +1,9 @@
1
1
  development:
2
2
  adapter: sqlite3
3
- encoding: utf8
4
- collation: utf8_general_ci
5
- reconnect: false
6
- database: store_active_record
3
+ database: ":memory:"
7
4
 
8
5
  test:
9
6
  adapter: sqlite3
10
- encoding: utf8
11
- collation: utf8_general_ci
12
- reconnect: false
13
- database: store_active_record_test
7
+ database: ":memory:"
14
8
 
15
9
  production: development
@@ -1,5 +1,5 @@
1
1
  class Store
2
2
  class ActiveRecord
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -13,7 +13,9 @@ class Store
13
13
 
14
14
  def insert(data)
15
15
  entity = cls.create(data)
16
- entity.id.to_s
16
+ id = entity.id.to_s
17
+ entity.update_attributes(data.merge('uid' => id))
18
+ id
17
19
  end
18
20
 
19
21
  def update(id, data)
@@ -53,8 +55,7 @@ class Store
53
55
 
54
56
  def to_hash
55
57
  attributes.tap do |a|
56
- a.delete('id')
57
- a['uid'] = uid
58
+ a.delete('id') # ActiveRecord detail
58
59
  end
59
60
  end
60
61
  end
data/spec/helper.rb CHANGED
@@ -13,6 +13,7 @@ require 'store/active_record'
13
13
  ensure
14
14
  ::ActiveRecord::Migration.create_table(table) do |t|
15
15
  t.string :foo
16
+ t.string :uid
16
17
  end
17
18
  end
18
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Owiesniak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-06 00:00:00.000000000 Z
11
+ date: 2013-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler