delegate_associations 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/delegate_associations.gemspec +1 -1
- data/lib/delegate_associations.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55c8f939e00d88a8e04e455fc167cc48c9554899
|
4
|
+
data.tar.gz: f35d2be7abd236669c2762ade7824df8893b03b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 788c54a7ff87d649d6dd3915c00431b66fe1dea43b243afc4fd789b92702990f0ea410afa66bf2869728a715239df157b510451047dce4d1f338a8f99f00e226
|
7
|
+
data.tar.gz: b2408877c82375762870110e126d5f607335dcb9bf5c614efffb70d208f6caa9a6df98ad84bc20e74a8503dbfccffdd6d87a038961712135531a65802bb73d0c
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "delegate_associations"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.2"
|
4
4
|
s.description = "A gem for delegate attributes and associations of belongs_to and has_one"
|
5
5
|
s.summary = "A gem for delegate attributes and associations of belongs_to and has_one"
|
6
6
|
s.homepage = "https://github.com/Brunomm/delegate_associations"
|
@@ -12,13 +12,13 @@ module DelegateAssociations
|
|
12
12
|
associations = [options.delete(:to)].flatten.compact.map!(&:to_sym)
|
13
13
|
valid_associations_to(associations)
|
14
14
|
|
15
|
-
|
15
|
+
except = [options[:except]].flatten.compact.map!(&:to_sym)
|
16
16
|
only = [options[:only]].flatten.compact.map!(&:to_sym)
|
17
|
-
|
17
|
+
except += delegate_exclude_columns
|
18
18
|
|
19
19
|
associations.each do |association|
|
20
20
|
reflect_on_association(association).klass.reflect_on_all_associations.each do |ass|
|
21
|
-
next unless ass.name.in?(get_deletage_methods(reflect_on_association(association).klass.reflect_on_all_associations.map(&:name),
|
21
|
+
next unless ass.name.in?(get_deletage_methods(reflect_on_association(association).klass.reflect_on_all_associations.map(&:name), except, only))
|
22
22
|
if ass.collection?
|
23
23
|
delegate "#{ass.name}", to: association, allow_nil: options[:allow_nil]
|
24
24
|
delegate "#{ass.name}=", to: association, allow_nil: options[:allow_nil]
|
@@ -42,12 +42,12 @@ module DelegateAssociations
|
|
42
42
|
#Valid if have an option[:to] and if association exists
|
43
43
|
valid_associations_to(associations)
|
44
44
|
|
45
|
-
|
45
|
+
except = [options[:except]].flatten.compact.map!(&:to_sym)
|
46
46
|
only = [options[:only]].flatten.compact.map!(&:to_sym)
|
47
|
-
|
47
|
+
except += delegate_exclude_columns
|
48
48
|
|
49
49
|
associations.each do |association|
|
50
|
-
get_deletage_methods(reflect_on_association(association).klass.column_names,
|
50
|
+
get_deletage_methods(reflect_on_association(association).klass.column_names, except, only).each do |attribute|
|
51
51
|
options[:suffix].each do |sf|
|
52
52
|
delegate "#{attribute}#{sf}", to: association, allow_nil: options[:allow_nil]
|
53
53
|
end
|
@@ -57,9 +57,9 @@ module DelegateAssociations
|
|
57
57
|
|
58
58
|
private
|
59
59
|
|
60
|
-
def get_deletage_methods(all_options,
|
60
|
+
def get_deletage_methods(all_options, except, only)
|
61
61
|
return (all_options.map(&:to_sym)&only)-delegate_exclude_columns if only.any?
|
62
|
-
all_options.map(&:to_sym) -
|
62
|
+
all_options.map(&:to_sym) - except
|
63
63
|
end
|
64
64
|
|
65
65
|
def valid_associations_to(associations)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delegate_associations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Mucelini Mergen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem for delegate attributes and associations of belongs_to and has_one
|
14
14
|
email:
|