delegate_associations 0.1.4 → 0.1.5
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 +5 -1
- data/lib/delegate_associations.rb +5 -4
- data/lib/delegate_associations/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e47bca41b0f9f48e5f10792e477dcc3b069e48b4
|
4
|
+
data.tar.gz: ae9f71f48201d36062554c8b3a920477e113bc52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf8445071d12e63a3572348b397a9ed880f2bb7766a4765f7b24363883385a7b0077a5ce08da1cfaeb5ace1cdc45255bb7fff918c374ffeb234fd717fce1b39
|
7
|
+
data.tar.gz: ec6b6e0d515c00bea7643e4d464c3a2a87fac4ac0f15731bd2513cbeeae8b8cc71f1a154fd3e6dae88da9084b9480bfaa8f9cfe8adbb2da5ca9ed7e4e8f1e158
|
@@ -1,10 +1,14 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/delegate_associations/version', __FILE__)
|
3
|
+
|
1
4
|
Gem::Specification.new do |s|
|
2
5
|
s.name = "delegate_associations"
|
3
|
-
s.version =
|
6
|
+
s.version = DelegateAssociations::VERSION
|
4
7
|
s.description = "A gem for delegate attributes and associations of belongs_to and has_one"
|
5
8
|
s.summary = "A gem for delegate attributes and associations of belongs_to and has_one"
|
6
9
|
s.homepage = "https://github.com/Brunomm/delegate_associations"
|
7
10
|
s.author = "Bruno Mucelini Mergen"
|
8
11
|
s.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,Rakefile,*.gemspec}"]
|
9
12
|
s.email = ["brunomergen@gmail.com"]
|
13
|
+
s.licenses = ['MIT']
|
10
14
|
end
|
@@ -37,7 +37,7 @@ module DelegateAssociations
|
|
37
37
|
def delegate_attributes(*opts)
|
38
38
|
options = {
|
39
39
|
suffix: ["","=","?","_before_type_cast","_change","_changed?","_was","_will_change!"],
|
40
|
-
except: [], only: [], allow_nil: false, to: []
|
40
|
+
except: [], only: [], allow_nil: false, to: [], prefix: nil
|
41
41
|
}
|
42
42
|
options.update(opts.extract_options!)
|
43
43
|
associations = [options.delete(:to)].flatten.compact.map!(&:to_sym)
|
@@ -45,8 +45,9 @@ module DelegateAssociations
|
|
45
45
|
#Valid if have an option[:to] and if association exists
|
46
46
|
valid_associations_to(associations)
|
47
47
|
|
48
|
-
except
|
49
|
-
only
|
48
|
+
except = [options[:except]].flatten.compact.map!(&:to_sym)
|
49
|
+
only = [options[:only]].flatten.compact.map!(&:to_sym)
|
50
|
+
prefix = options[:prefix]
|
50
51
|
except += delegate_exclude_columns
|
51
52
|
|
52
53
|
# I need "begin" because have a problem with Devise when I run migrations
|
@@ -55,7 +56,7 @@ module DelegateAssociations
|
|
55
56
|
associations.each do |association|
|
56
57
|
get_deletage_methods(reflect_on_association(association).klass.column_names, except, only).each do |attribute|
|
57
58
|
options[:suffix].each do |sf|
|
58
|
-
delegate "#{attribute}#{sf}", to: association, allow_nil: options[:allow_nil]
|
59
|
+
delegate "#{attribute}#{sf}", to: association, allow_nil: options[:allow_nil], prefix: prefix
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
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.5
|
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:
|
11
|
+
date: 2016-06-10 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:
|
@@ -22,7 +22,8 @@ files:
|
|
22
22
|
- lib/delegate_associations.rb
|
23
23
|
- lib/delegate_associations/version.rb
|
24
24
|
homepage: https://github.com/Brunomm/delegate_associations
|
25
|
-
licenses:
|
25
|
+
licenses:
|
26
|
+
- MIT
|
26
27
|
metadata: {}
|
27
28
|
post_install_message:
|
28
29
|
rdoc_options: []
|
@@ -40,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
41
|
version: '0'
|
41
42
|
requirements: []
|
42
43
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
44
|
+
rubygems_version: 2.5.1
|
44
45
|
signing_key:
|
45
46
|
specification_version: 4
|
46
47
|
summary: A gem for delegate attributes and associations of belongs_to and has_one
|