activerecord_to_poro 0.0.8 → 0.0.9

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: 8dd9ccad82ce27decc321a3ecc0e46ee03ae03a2
4
- data.tar.gz: e5efe27480922d9306c038d098ef6d76872507c2
3
+ metadata.gz: 1d07a91d246c4e9b3d0f758d871c6cdc9390f7f1
4
+ data.tar.gz: 848dda5dad35ff0b94775f4467580dcbe5a57f1b
5
5
  SHA512:
6
- metadata.gz: dcdc20ef41bea88a23bc9066e1e5a767494af88d8313990e7bc577a7b8107c03528b7fbdf93c497e90d7f30390b0fa99c12a7b4c3b8cda3712098cb674519344
7
- data.tar.gz: e9ff0ac70f6b78a0ebe6c77545a0fe87b34fd6bea9a60e99c627543c87236235ae278a6825b1bb16b39b2118b7f417d4974e31f594ab55908d27c6947322e45c
6
+ metadata.gz: 74e9b3544bde6cf80cc394ba30e4fc13d5c1481e9943201b01d95df4c60e1c7e6c052b9e4d5236c37bc02f32d6999c1678b1a80dfa3fd062650597dc11543702
7
+ data.tar.gz: 1b80a95b618aed044e31c71b8093afef9472238383b4df2f1ffd383239e7fb4a35f782acb850fc78e95fe7eb1d35da8cc3943b01e476812c3c751d161489eec9
@@ -0,0 +1,3 @@
1
+ ### 0.0.9 (Janury 9, 2014)
2
+
3
+ * [#11](https://github.com/slowjack2k/activerecord_to_poro/pull/11): Fixes for Rails 4.2 - [@slowjack2k](https://github.com/slowjack2k).
@@ -26,7 +26,9 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "bundler", "~> 1.5"
27
27
  spec.add_development_dependency "rake"
28
28
  spec.add_development_dependency 'sqlite3'
29
- spec.add_development_dependency 'activerecord', '4.0.2'
29
+ spec.add_development_dependency 'pg'
30
+ # spec.add_development_dependency 'activerecord', '4.0.2'
31
+ spec.add_development_dependency 'activerecord', '4.2.0'
30
32
  spec.add_development_dependency 'database_cleaner'
31
33
 
32
34
 
@@ -44,14 +44,17 @@ module ActiverecordToPoro
44
44
  module_function
45
45
 
46
46
  def is_an_ar_collection?(ar_class, association_name)
47
- (ar_class.reflections[association_name] &&
48
- ar_class.reflections[association_name].collection?)
47
+ ref = reflection_for_association(ar_class, association_name)
48
+ (ref && ref.collection?)
49
49
  end
50
50
 
51
51
  def is_an_has_many_through(ar_class, association_name)
52
- ar_class.reflections[association_name] &&
53
- ar_class.reflections[association_name].macro == :has_many &&
54
- ar_class.reflections[association_name].options.has_key?(:through)
52
+ ref = reflection_for_association(ar_class, association_name)
53
+ ref && ref.macro == :has_many && ref.options.has_key?(:through)
54
+ end
55
+
56
+ def reflection_for_association(ar_class, association_name)
57
+ ar_class.reflections[association_name.to_sym] || ar_class.reflections[association_name.to_s]
55
58
  end
56
59
 
57
60
  end
@@ -14,7 +14,6 @@ module ActiverecordToPoro
14
14
  end
15
15
 
16
16
  def _update_poro_metadata
17
-
18
17
  _referenced_poros.each do |entity|
19
18
  entity._set_metadata_from_ar = self if entity.respond_to? :_set_metadata_from_ar=
20
19
 
@@ -39,7 +38,7 @@ module ActiverecordToPoro
39
38
 
40
39
  record.tap do |new_obj|
41
40
 
42
- new_obj.attributes = attrs
41
+ new_obj.attributes = attrs || {}
43
42
 
44
43
  _patch_has_many_members(attrs, new_obj) unless new_obj.new_record?
45
44
  end
@@ -77,7 +76,7 @@ module ActiverecordToPoro
77
76
  end
78
77
 
79
78
  def _extract_metadata!(attrs)
80
- metadata = (attrs || {}).delete(:_set_metadata_to_ar) { |*| Metadata.new }
79
+ metadata = (attrs || {}).delete(:_set_metadata_to_ar){ |*| Metadata.new }
81
80
  metadata.for_ar_class(self.name)
82
81
  end
83
82
 
@@ -1,3 +1,3 @@
1
1
  module ActiverecordToPoro
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -1,18 +1,28 @@
1
1
  require 'active_record'
2
- require 'database_cleaner'
3
2
 
4
3
  db_dir = File.join(File.expand_path(__dir__ ), "ar_support/db/")
5
4
  # ENV['DATABASE_URL']="sqlite3://localhost/:memory:?pool=5&timeout=5000"
6
5
 
6
+ con_settings = {
7
+ pool: 5,
8
+ timeout: 5000,
9
+ database: ":memory:",
10
+ adapter: "sqlite3"
11
+ }
12
+
13
+ # con_settings = {
14
+ # adapter: 'postgresql',
15
+ # encoding: 'utf8',
16
+ # pool: 5,
17
+ # host: 'localhost',
18
+ # port: 5000,
19
+ # database: 'poro_test'
20
+ # }
7
21
 
22
+ require 'database_cleaner'
8
23
 
9
- ActiveRecord::Base.establish_connection({
10
- pool: 5,
11
- timeout: 5000,
12
- database: ":memory:",
13
- adapter: "sqlite3"
14
- })
15
-
24
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
25
+ ActiveRecord::Base.establish_connection(con_settings)
16
26
  ActiveRecord::Migrator.migrate "#{db_dir}/migrate"
17
27
 
18
28
  Dir[File.join(File.expand_path(__dir__ ), "ar_support/models/**/*.rb")].each { |f| require f }
@@ -20,8 +30,8 @@ Dir[File.join(File.expand_path(__dir__ ), "ar_support/models/**/*.rb")].each { |
20
30
  RSpec.configure do |config|
21
31
 
22
32
  config.before(:suite) do
23
- DatabaseCleaner.strategy = :transaction
24
- DatabaseCleaner.clean_with(:truncation)
33
+ DatabaseCleaner.strategy = :truncation, {:except => %w[schema_migrations public.schema_migrations]}
34
+ DatabaseCleaner.clean_with(:truncation, {:except => %w[schema_migrations public.schema_migrations]})
25
35
  end
26
36
 
27
37
  config.before(:each) do
@@ -4,30 +4,30 @@ class CreateMyArClass < ActiveRecord::Migration
4
4
  t.string :name
5
5
  t.string :email
6
6
  t.integer :salutation_id
7
- t.integer :lock_version
7
+ t.integer :lock_version, default: 0
8
8
  end
9
9
 
10
10
  create_table :roles do |t|
11
11
  t.string :name
12
12
  t.integer :user_id
13
- t.integer :lock_version
13
+ t.integer :lock_version, default: 0
14
14
  end
15
15
 
16
16
  create_table :permissions do |t|
17
17
  t.string :name
18
18
  t.integer :role_id
19
- t.integer :lock_version
19
+ t.integer :lock_version, default: 0
20
20
  end
21
21
 
22
22
  create_table :salutations do |t|
23
23
  t.string :name
24
- t.integer :lock_version
24
+ t.integer :lock_version, default: 0
25
25
  end
26
26
 
27
27
  create_table :addresses do |t|
28
28
  t.string :street
29
29
  t.integer :user_id
30
- t.integer :lock_version
30
+ t.integer :lock_version, default: 0
31
31
  end
32
32
  end
33
33
  end
@@ -1,3 +1,3 @@
1
1
  class Address < ActiveRecord::Base
2
- belongs_to :user, autosave: true
2
+ belongs_to :user
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Permission < ActiveRecord::Base
2
- belongs_to :role, autosave: true
2
+ belongs_to :role
3
3
  end
@@ -1,4 +1,4 @@
1
1
  class Role < ActiveRecord::Base
2
2
  has_many :permissions, autosave: true
3
- belongs_to :user, autosave: true
3
+ belongs_to :user
4
4
  end
@@ -2,7 +2,7 @@ class User < ActiveRecord::Base
2
2
  has_many :roles, autosave: true
3
3
  has_many :permissions, through: :roles, autosave: true
4
4
 
5
- belongs_to :salutation, autosave: true
5
+ belongs_to :salutation
6
6
  has_one :address, autosave: true
7
7
 
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_to_poro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dieter Späth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-18 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_type
@@ -80,20 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pg
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: activerecord
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - '='
88
102
  - !ruby/object:Gem::Version
89
- version: 4.0.2
103
+ version: 4.2.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - '='
95
109
  - !ruby/object:Gem::Version
96
- version: 4.0.2
110
+ version: 4.2.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: database_cleaner
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -271,6 +285,7 @@ extra_rdoc_files: []
271
285
  files:
272
286
  - ".gitignore"
273
287
  - ".travis.yml"
288
+ - CHANGELOG.md
274
289
  - Gemfile
275
290
  - Guardfile
276
291
  - LICENSE.txt