acts_as_sourceable 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/acts_as_sourceable/acts_as_sourceable.rb +11 -19
- metadata +5 -7
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTM4YjRkMGUzYTZhNjE3NTJkYjk4ZmRjOTRlNTg1Zjg1OTg5YmQ0Yw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDRiMjZjMDczZGI1YTVhMmY1MWVmYzc2N2I4YjRhNGZlNjdmNmUxNQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODc4ZTMwMWI2MjUwNjYxOTRmMGQ1NjgxZDRiOTQ1MzEwZmYxYTJhYzI1OThj
|
10
|
+
ZmJkMjhhODM4OTY1MThiYmU5ZGE2YjVlYTE0NzM2ZmRiZGNmMDBjNTJiYjIw
|
11
|
+
YThlYzFiMDJjM2QxYWYzZTk3ZjViOThlYTk1OWZhOTgyYTgwYTc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTA1M2M1ZGYyNzUzYTY0OGNjYTI4MjFmZTM1ZWUzYzI2OWJjM2VhNjllNzRk
|
14
|
+
ZGYxMGYxZDZkODZhNTc2M2IwNjJjMTA1Y2RiZTdlYWUwMWI5MzU5NzZlN2Rh
|
15
|
+
NGYzMDBkNzBmYWNmMTJjYmE5YjhiZWViMmQ5MDU0ZTYyOTQzNTA=
|
@@ -27,37 +27,29 @@ module ActsAsSourceable
|
|
27
27
|
# Elsif the records can be derived, we need to check the flattened item tables for any references
|
28
28
|
# Else we check the registry_entries to see if the record has a recorded source
|
29
29
|
if options[:cache_column]
|
30
|
-
scope :sourced, where(options[:cache_column] => true)
|
31
|
-
scope :unsourced, where(options[:cache_column] => false)
|
30
|
+
scope :sourced, lambda { where(options[:cache_column] => true) }
|
31
|
+
scope :unsourced, lambda { where(options[:cache_column] => false) }
|
32
32
|
elsif options[:through]
|
33
|
-
scope :sourced, joins(options[:through]).group("#{table_name}.#{primary_key}") do
|
34
|
-
|
35
|
-
end
|
36
|
-
scope :unsourced, joins("LEFT OUTER JOIN (#{sourced.to_sql}) sourced ON sourced.id = #{table_name}.id").where("sourced.id IS NULL")
|
33
|
+
scope :sourced, lambda { joins(options[:through]).group("#{table_name}.#{primary_key}") } do include ActsAsSourceable::GroupScopeExtensions; end
|
34
|
+
scope :unsourced, lambda { joins("LEFT OUTER JOIN (#{sourced.to_sql}) sourced ON sourced.id = #{table_name}.id").where("sourced.id IS NULL") }
|
37
35
|
else
|
38
|
-
scope :sourced, joins(:sourceable_registry_entries).group("#{table_name}.#{primary_key}") do
|
39
|
-
|
40
|
-
end
|
41
|
-
scope :unsourced, joins("LEFT OUTER JOIN (#{ActsAsSourceable::RegistryEntry.select('sourceable_id AS id').where(:sourceable_type => self).to_sql}) sourced ON sourced.id = #{table_name}.id").where("sourced.id IS NULL")
|
36
|
+
scope :sourced, lambda { joins(:sourceable_registry_entries).group("#{table_name}.#{primary_key}") } do include ActsAsSourceable::GroupScopeExtensions; end
|
37
|
+
scope :unsourced, lambda { joins("LEFT OUTER JOIN (#{ActsAsSourceable::RegistryEntry.select('sourceable_id AS id').where(:sourceable_type => self).to_sql}) sourced ON sourced.id = #{table_name}.id").where("sourced.id IS NULL") }
|
42
38
|
end
|
43
39
|
|
44
40
|
# Add a way of finding everything sourced by a particular set of records
|
45
41
|
if options[:through]
|
46
|
-
|
47
|
-
self.joins(acts_as_sourceable_options[:through]).where(reflect_on_association(acts_as_sourceable_options[:through]).table_name => {:id => source.id})
|
48
|
-
end
|
42
|
+
scope :sourced_by, lambda { |source| joins(options[:through]).where(reflect_on_association(options[:through]).table_name => {:id => source.id}) }
|
49
43
|
else
|
50
|
-
|
51
|
-
self.joins(:sourceable_registry_entries).where(ActsAsSourceable::RegistryEntry.table_name => {:source_type => source.class, :source_id => source.id}).uniq
|
52
|
-
end
|
44
|
+
scope :sourced_by, lambda { |source| joins(:sourceable_registry_entries).where(ActsAsSourceable::RegistryEntry.table_name => {:source_type => source.class, :source_id => source.id}).uniq }
|
53
45
|
end
|
54
46
|
|
55
47
|
# Create a scope that returns record that is not used by the associations in options[:used_by]
|
56
48
|
if options[:used_by]
|
57
|
-
scope :unused, where(Array(options[:used_by]).collect {|usage_association| "#{table_name}.id NOT IN (" + select("#{table_name}.id").joins(usage_association).group("#{table_name}.id").to_sql + ")"}.join(' AND '))
|
58
|
-
scope :orphaned, unsourced.unused
|
49
|
+
scope :unused, lambda { where(Array(options[:used_by]).collect {|usage_association| "#{table_name}.id NOT IN (" + select("#{table_name}.id").joins(usage_association).group("#{table_name}.id").to_sql + ")"}.join(' AND ')) }
|
50
|
+
scope :orphaned, lambda { unsourced.unused }
|
59
51
|
else
|
60
|
-
scope :orphaned, unsourced
|
52
|
+
scope :orphaned, lambda { unsourced }
|
61
53
|
end
|
62
54
|
|
63
55
|
# ACTIVE RELATION SETUP
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_sourceable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Nicholas Jakobsen
|
@@ -10,7 +9,7 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
14
|
description: Allows the RRN to perform garbage collection on categories that are no
|
16
15
|
longer referenced.
|
@@ -25,26 +24,25 @@ files:
|
|
25
24
|
- README.md
|
26
25
|
homepage: http://github.com/rrn/acts_as_sourceable
|
27
26
|
licenses: []
|
27
|
+
metadata: {}
|
28
28
|
post_install_message:
|
29
29
|
rdoc_options: []
|
30
30
|
require_paths:
|
31
31
|
- lib
|
32
32
|
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
33
|
requirements:
|
35
34
|
- - ! '>='
|
36
35
|
- !ruby/object:Gem::Version
|
37
36
|
version: '0'
|
38
37
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
38
|
requirements:
|
41
39
|
- - ! '>='
|
42
40
|
- !ruby/object:Gem::Version
|
43
41
|
version: '0'
|
44
42
|
requirements: []
|
45
43
|
rubyforge_project:
|
46
|
-
rubygems_version:
|
44
|
+
rubygems_version: 2.0.0
|
47
45
|
signing_key:
|
48
|
-
specification_version:
|
46
|
+
specification_version: 4
|
49
47
|
summary: perform garbage collection on categories that are no longer referenced
|
50
48
|
test_files: []
|