activemodel-associations 0.0.2 → 0.0.3

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: 3d9c6e4e10b3abbddc32adb581c7986a5cb62efc
4
- data.tar.gz: 5dc2e3d9acb6351c8d041f252e43454d221bd3e9
3
+ metadata.gz: 017e2f0b46163726880d4703ec352add2b9b9b05
4
+ data.tar.gz: b5afa0902988cd9cae5656126178bc720d2fc12d
5
5
  SHA512:
6
- metadata.gz: bdb223dd6a00f9571869a04cde42dbaabe997fefd9a02fc9bb9dac6ceb964b48f36ef84f5b8c41f259083ff7ddc315875013e01278cb6038961ce63919669e09
7
- data.tar.gz: 1b75beaef925ef9149e7ebcefaf167eb094263a2b552224e56972d5ea6fafa331ab293d0960679378bbf71ffcf3813b910b19fe93bacd07f31749c615a48db8d
6
+ metadata.gz: 57be72dc156c9913ed2de207b866385eb32391263b5d81f7695a431c9c54fe701bab046d2f608111be3d6fa75facf14d1744eca905231d719c1717338773c85c
7
+ data.tar.gz: bbbed9c4019bf1a309c4670ff54802dae9e04db77795882b171f59a4b2db1d5af10e2859eb947f44bbd03ca5ccb3185a158aca09da7c53dcd52f648184f4a0b4
data/.travis.yml CHANGED
@@ -5,3 +5,4 @@ rvm:
5
5
  gemfile:
6
6
  - gemfiles/activerecord-40.gemfile
7
7
  - gemfiles/activerecord-41.gemfile
8
+ - gemfiles/activerecord-42.gemfile
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ RSpec::Core::RakeTask.new(:spec)
6
6
  task :default => :spec
7
7
 
8
8
  namespace :spec do
9
- %w(activerecord-40 activerecord-41).each do |gemfile|
9
+ %w(activerecord-40 activerecord-41 activerecord-412 activerecord-42).each do |gemfile|
10
10
  desc "Run Tests by #{gemfile}.gemfile"
11
11
  task gemfile do
12
12
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle install --path .bundle"
@@ -16,7 +16,7 @@ namespace :spec do
16
16
 
17
17
  desc "Run All Tests"
18
18
  task :all do
19
- %w(activerecord-40 activerecord-41).each do |gemfile|
19
+ %w(activerecord-40 activerecord-41 activerecord-412 activerecord-42).each do |gemfile|
20
20
  Rake::Task["spec:#{gemfile}"].invoke
21
21
  end
22
22
  end
@@ -29,4 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "sqlite3"
30
30
  spec.add_development_dependency "database_cleaner"
31
31
  spec.add_development_dependency "coveralls"
32
+ spec.add_development_dependency "byebug"
33
+ spec.add_development_dependency "pry"
34
+ spec.add_development_dependency "pry-byebug"
32
35
  end
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "activerecord", "~> 4.1.0"
4
- gem "activemodel", "~> 4.1.0"
5
- gem "activesupport", "~> 4.1.0"
3
+ gem "activerecord", "~> 4.1.0", "<= 4.1.1"
4
+ gem "activemodel", "~> 4.1.0", "<= 4.1.1"
5
+ gem "activesupport", "~> 4.1.0", "<= 4.1.1"
6
6
 
7
7
  gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 4.1.2"
4
+ gem "activemodel", "~> 4.1.2"
5
+ gem "activesupport", "~> 4.1.2"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", github: "rails/rails"
4
+ gem "arel", github: "rails/arel"
5
+ gem "activemodel", github: "rails/rails"
6
+ gem "activesupport", github: "rails/rails"
7
+
8
+ gemspec :path => "../"
@@ -3,8 +3,13 @@ module ActiveModel::Associations
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- class_attribute :reflections
7
- self.reflections = {}
6
+ if ActiveRecord.version.to_s >= "4.1.2"
7
+ class_attribute :_reflections
8
+ self._reflections = ActiveSupport::HashWithIndifferentAccess.new
9
+ else
10
+ class_attribute :reflections
11
+ self.reflections = {}
12
+ end
8
13
  end
9
14
 
10
15
  module ClassMethods
@@ -22,7 +27,11 @@ module ActiveModel::Associations
22
27
  end
23
28
 
24
29
  def reflect_on_association(association)
25
- reflections[association]
30
+ if ActiveRecord.version.to_s >= "4.1.2"
31
+ _reflections[association.to_s]
32
+ else
33
+ reflections[association]
34
+ end
26
35
  end
27
36
  end
28
37
  end
@@ -52,6 +52,10 @@ module ActiveModel::Associations
52
52
  association
53
53
  end
54
54
 
55
+ def read_attribute(name)
56
+ send(name)
57
+ end
58
+
55
59
  private
56
60
 
57
61
  # override
@@ -1,5 +1,5 @@
1
1
  module ActiveModel
2
2
  module Associations
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -50,5 +50,14 @@ module ActiveRecord::Associations
50
50
 
51
51
  target
52
52
  end
53
+
54
+ private
55
+
56
+ def get_records
57
+ return scope.to_a if reflection.scope_chain.any?(&:any?)
58
+
59
+ target_ids = reflection.options[:target_ids]
60
+ klass.where(id: owner[target_ids]).to_a
61
+ end
53
62
  end
54
63
  end
@@ -53,7 +53,7 @@ describe ActiveModel::Associations do
53
53
  end
54
54
 
55
55
  it "can validate" do
56
- expect(comment.valid?).to be_true
56
+ expect(comment.valid?).to be_truthy
57
57
  end
58
58
  end
59
59
 
@@ -180,7 +180,7 @@ describe ActiveModel::Associations do
180
180
  end
181
181
 
182
182
  it "can validate" do
183
- expect(group.valid?).to be_true
183
+ expect(group.valid?).to be_truthy
184
184
  end
185
185
  end
186
186
 
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,9 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'coveralls'
3
3
  Coveralls.wear!
4
4
 
5
+ require 'byebug'
6
+ require 'pry-byebug'
7
+
5
8
  require 'activemodel/associations'
6
9
  ActiveModel::Associations::Hooks.init
7
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel-associations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -150,6 +150,48 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: pry-byebug
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
153
195
  description: ActiveRecord Association Helper for PORO (Plain Old Ruby Object)
154
196
  email:
155
197
  - kakyoin.hierophant@gmail.com
@@ -167,6 +209,8 @@ files:
167
209
  - activemodel-associations.gemspec
168
210
  - gemfiles/activerecord-40.gemfile
169
211
  - gemfiles/activerecord-41.gemfile
212
+ - gemfiles/activerecord-412.gemfile
213
+ - gemfiles/activerecord-42.gemfile
170
214
  - lib/active_model/associations.rb
171
215
  - lib/active_model/associations/active_record_reflection.rb
172
216
  - lib/active_model/associations/association_scope_extension.rb