auto_scopes 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/config/initializers/auto_scopes.rb +1 -1
- data/lib/auto_scopes.rb +6 -5
- data/lib/auto_scopes/models.rb +17 -0
- data/lib/auto_scopes/version.rb +1 -1
- metadata +4 -4
- data/lib/auto_scopes/check_models.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 569474ab096aa154abfb1418fa24d56c2d31ff94
|
4
|
+
data.tar.gz: e9f64ebac428472198f3349c5cfc93077f1396b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d731f6deb7b64d9146370c5c01a2f0afd0511289780d8e6faaf03128c01e4b8ee3333b72e0fc0b469cc681739ba54c14629d371e8b737849b5c4b570b08c383
|
7
|
+
data.tar.gz: b37db864c4e60a5a6bd2671154edf5c10491a7c3e92db53f36fdde3ee10949e2085bafd1029cdb00f98e144f3b9fabbb8791351c5a11947e51b4a1bdcadb5dac
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# AutoScopes
|
2
2
|
[](https://travis-ci.org/victor95pc/auto-scopes)
|
3
|
+
[](https://gemnasium.com/victor95pc/auto-scopes)
|
3
4
|
|
4
5
|
Recycle already defined scopes on multiple models whatever the association are, making your models way more DRYer
|
5
6
|
|
@@ -103,7 +104,7 @@ end
|
|
103
104
|
If you dont want this behavior you can set the option create_scope_for_association to false
|
104
105
|
```ruby
|
105
106
|
# config/initializers/auto_scopes.rb
|
106
|
-
AutoScopes.
|
107
|
+
AutoScopes.setup do |c|
|
107
108
|
c.create_scope_for_association = false
|
108
109
|
end
|
109
110
|
```
|
@@ -5,7 +5,7 @@
|
|
5
5
|
#
|
6
6
|
# scope_association_prefix: in each association the parent model
|
7
7
|
# this is the prefix added to them
|
8
|
-
AutoScopes.
|
8
|
+
AutoScopes.setup do |c|
|
9
9
|
# c.auto_scopes_location = 'config/auto_scopes'
|
10
10
|
# c.create_scope_for_association = true
|
11
11
|
# c.scope_association_prefix = 'by'
|
data/lib/auto_scopes.rb
CHANGED
@@ -9,12 +9,12 @@ require 'active_record'
|
|
9
9
|
require "auto_scopes/version"
|
10
10
|
require "auto_scopes/associations_methods"
|
11
11
|
require "auto_scopes/associations_chains"
|
12
|
-
require "auto_scopes/
|
12
|
+
require "auto_scopes/models"
|
13
13
|
|
14
14
|
module AutoScopes
|
15
15
|
include Configurations
|
16
16
|
|
17
|
-
configurable :
|
17
|
+
configurable :scope_association_prefix, :create_scope_for_association, :auto_scopes_location
|
18
18
|
|
19
19
|
configuration_defaults do |c|
|
20
20
|
c.auto_scopes_location = 'config/auto_scopes'
|
@@ -24,11 +24,12 @@ module AutoScopes
|
|
24
24
|
|
25
25
|
class << self
|
26
26
|
def config
|
27
|
-
|
27
|
+
configuration
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
|
30
|
+
def setup(&block)
|
31
|
+
AutoScopes.configure(&block)
|
32
|
+
AutoScopes::Models.check!
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AutoScopes
|
2
|
+
module Models
|
3
|
+
class << self
|
4
|
+
def check!
|
5
|
+
load_association_file.each_pair do |model, associations|
|
6
|
+
AssociationsChains.new(model.constantize, associations, []).look_inside_chain
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def load_association_file
|
13
|
+
YAML.load_file(Rails.root.join(AutoScopes.config.auto_scopes_location + '.yml')) || []
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/auto_scopes/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_scopes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- victor95pc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -171,7 +171,7 @@ files:
|
|
171
171
|
- lib/auto_scopes.rb
|
172
172
|
- lib/auto_scopes/associations_chains.rb
|
173
173
|
- lib/auto_scopes/associations_methods.rb
|
174
|
-
- lib/auto_scopes/
|
174
|
+
- lib/auto_scopes/models.rb
|
175
175
|
- lib/auto_scopes/version.rb
|
176
176
|
- lib/generators/auto_scopes/install_generator.rb
|
177
177
|
homepage: https://github.com/victor95pc/auto-scopes
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
195
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.4.
|
196
|
+
rubygems_version: 2.4.8
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Recycle already defined scopes on multiple models whatever the association
|