unscoped_associations 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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', git: 'git@github.com:markets/unscoped_associations.git'
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
- ## Todo
47
- A lot of stuff.
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.2.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
- define_singular_association(association_name, options)
38
+ define_unscoped_association(association_name, options)
39
39
  end
40
40
 
41
41
  def add_unscoped_has_many(association_name, options)
42
- define_collection_association(association_name, options)
42
+ define_unscoped_association(association_name, options)
43
43
  end
44
44
 
45
45
  def add_unscoped_has_one(association_name, options)
46
- define_singular_association(association_name, options)
46
+ define_unscoped_association(association_name, options)
47
47
  end
48
48
 
49
- def define_singular_association(association_name, options)
49
+ def define_unscoped_association(association_name, options)
50
50
  define_method(association_name) do
51
- klass_name = options[:class_name] || association_name.to_s.camelize
52
- instance = "@unscoped_#{association_name}"
53
- instance_variable_get(instance) ||
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.2.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-21"
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.2.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-21 00:00:00.000000000 Z
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: 915012721
106
+ hash: -147620979
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements: