unscoped_associations 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +14 -3
- data/VERSION +1 -1
- data/lib/unscoped_associations.rb +7 -17
- data/unscoped_associations.gemspec +2 -2
- metadata +3 -3
data/README.md
CHANGED
@@ -10,7 +10,13 @@ Do it easily with this lib. Supported associations:
|
|
10
10
|
Add this line to you Gemfile:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'unscoped_associations'
|
13
|
+
gem 'unscoped_associations'
|
14
|
+
```
|
15
|
+
|
16
|
+
Or install the gem:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem install unscoped_associations
|
14
20
|
```
|
15
21
|
|
16
22
|
## Usage
|
@@ -43,8 +49,13 @@ end
|
|
43
49
|
|
44
50
|
```
|
45
51
|
|
46
|
-
##
|
47
|
-
|
52
|
+
## Status
|
53
|
+
Tested on Rails 3.2.
|
54
|
+
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
Ideas, fixes, improvements or any comment are welcome!
|
58
|
+
|
48
59
|
|
49
60
|
## License
|
50
61
|
Copyright (c) 2013 Marc Anguera. Unscoped Associations is released under the [MIT](http://opensource.org/licenses/MIT) License.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -35,32 +35,22 @@ module UnscopedAssociations
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def add_unscoped_belongs_to(association_name, options)
|
38
|
-
|
38
|
+
define_unscoped_association(association_name, options)
|
39
39
|
end
|
40
40
|
|
41
41
|
def add_unscoped_has_many(association_name, options)
|
42
|
-
|
42
|
+
define_unscoped_association(association_name, options)
|
43
43
|
end
|
44
44
|
|
45
45
|
def add_unscoped_has_one(association_name, options)
|
46
|
-
|
46
|
+
define_unscoped_association(association_name, options)
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def define_unscoped_association(association_name, options)
|
50
50
|
define_method(association_name) do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
instance_variable_set(instance, klass_name.constantize.unscoped { super(association_name) })
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def define_collection_association(association_name, options)
|
59
|
-
define_method(association_name) do
|
60
|
-
klass_name = options[:class_name] || association_name.to_s.camelize.singularize
|
61
|
-
instances = "@unscoped_#{association_name}"
|
62
|
-
instance_variable_get(instances) ||
|
63
|
-
instance_variable_set(instances, klass_name.constantize.unscoped { super(association_name) })
|
51
|
+
self.class.reflect_on_association(association_name).klass.unscoped {
|
52
|
+
super(association_name)
|
53
|
+
}
|
64
54
|
end
|
65
55
|
end
|
66
56
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "unscoped_associations"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["markets"]
|
12
|
-
s.date = "2013-05
|
12
|
+
s.date = "2013-06-05"
|
13
13
|
s.description = "Skip default_scope in your associations"
|
14
14
|
s.email = "srmarc.ai@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unscoped_associations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05
|
12
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
segments:
|
105
105
|
- 0
|
106
|
-
hash:
|
106
|
+
hash: -147620979
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|