dependent_restrict 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/dependent_restrict.gemspec +4 -3
- data/gemfiles/rails4_0.gemfile +13 -0
- data/gemfiles/{rails4.gemfile → rails4_1.gemfile} +0 -0
- data/lib/dependent_restrict.rb +2 -1
- data/spec/dependent_restrict_spec.rb +13 -0
- data/spec/schema.rb +7 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98d742af335bdd2b42c95160496b044c555c2fc1
|
4
|
+
data.tar.gz: 7e2b5342a2c9ce2e2d3a8f842b1221109a3317f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7e03ba470c1621de281bfebcc90f085502bc11c5f848e36065bf04e8b47049c516334fb08ed24fe4e61e36dba901ca97bc1ae40fb3570052a20e110b0ac3960
|
7
|
+
data.tar.gz: a06010a30a0ff6f5edff714928ac009ee42bb857a616e8ca03ddb92239a1773360db3d34c2c9e6c8860e71c85a2cfcc554f3256b4c50112ba37288903516ef05
|
data/Gemfile
CHANGED
@@ -2,11 +2,12 @@ source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
3
3
|
|
4
4
|
group :development, :test do
|
5
|
+
gem 'pry-debugger'
|
5
6
|
gem 'rake', '~> 0.9.2'
|
6
7
|
gem 'rdoc', '~> 3.12'
|
7
8
|
gem 'rspec'
|
8
9
|
gem 'simplecov'
|
9
10
|
gem 'simplecov-rcov'
|
10
11
|
gem 'sqlite3'
|
11
|
-
gem 'activerecord', '~> 4.0'
|
12
|
+
gem 'activerecord', '~> 4.0.0'
|
12
13
|
end
|
data/dependent_restrict.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'dependent_restrict'
|
16
|
-
s.version = '0.2.
|
17
|
-
s.date = '2014-05-
|
16
|
+
s.version = '0.2.1'
|
17
|
+
s.date = '2014-05-09'
|
18
18
|
s.rubyforge_project = 'dependent_restrict'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -66,7 +66,8 @@ Gem::Specification.new do |s|
|
|
66
66
|
dependent_restrict.gemspec
|
67
67
|
gemfiles/rails2.gemfile
|
68
68
|
gemfiles/rails3.gemfile
|
69
|
-
gemfiles/
|
69
|
+
gemfiles/rails4_0.gemfile
|
70
|
+
gemfiles/rails4_1.gemfile
|
70
71
|
lib/dependent_restrict.rb
|
71
72
|
lib/dependent_restrict/delete_restriction_error.rb
|
72
73
|
spec/dependent_restrict_spec.rb
|
File without changes
|
data/lib/dependent_restrict.rb
CHANGED
@@ -2,7 +2,7 @@ require 'active_record'
|
|
2
2
|
require 'dependent_restrict/delete_restriction_error'
|
3
3
|
|
4
4
|
module DependentRestrict
|
5
|
-
VERSION = '0.2.
|
5
|
+
VERSION = '0.2.1'
|
6
6
|
|
7
7
|
def self.included(base)
|
8
8
|
super
|
@@ -45,6 +45,7 @@ module DependentRestrict
|
|
45
45
|
|
46
46
|
def has_and_belongs_to_many_with_restrict(association_id, options = {}, &extension)
|
47
47
|
reflection = if active_record_4?
|
48
|
+
raise ArgumentError, "dependent_restrict doesn't work with has_and_belongs_to_many. Use equivalent rails 4.1 has_many :through" if ActiveRecord::Reflection.respond_to? :create
|
48
49
|
restrict_create_reflection(:has_and_belongs_to_many, association_id, options, scope ||= {}, self)
|
49
50
|
else
|
50
51
|
create_reflection(:has_and_belongs_to_many, association_id, options, self)
|
@@ -31,6 +31,19 @@ describe DependentRestrict do
|
|
31
31
|
"Category #{id}"
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
class ProductsCategory < ActiveRecord::Base
|
36
|
+
belongs_to :product
|
37
|
+
belongs_to :category
|
38
|
+
end
|
39
|
+
|
40
|
+
class Product < ActiveRecord::Base
|
41
|
+
if ActiveRecord::Reflection.respond_to? :create
|
42
|
+
has_many :categories, :through => :products_categories
|
43
|
+
else
|
44
|
+
has_and_belongs_to_many :categories
|
45
|
+
end
|
46
|
+
end
|
34
47
|
end
|
35
48
|
|
36
49
|
after do
|
data/spec/schema.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependent_restrict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -46,7 +46,8 @@ files:
|
|
46
46
|
- dependent_restrict.gemspec
|
47
47
|
- gemfiles/rails2.gemfile
|
48
48
|
- gemfiles/rails3.gemfile
|
49
|
-
- gemfiles/
|
49
|
+
- gemfiles/rails4_0.gemfile
|
50
|
+
- gemfiles/rails4_1.gemfile
|
50
51
|
- lib/dependent_restrict.rb
|
51
52
|
- lib/dependent_restrict/delete_restriction_error.rb
|
52
53
|
- spec/dependent_restrict_spec.rb
|