denormalize_fields 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/denormalize_fields/association_extension.rb +25 -0
- data/lib/denormalize_fields/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0236da61bb8d620a30c1d80b5e2915655c3fa172209e48e4a0574319bab02318
|
4
|
+
data.tar.gz: 186179fca7937e35b792f44d859c58febe38bdc28c1ea7e41b347a7280919d02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18db814fcaaa2e8a8c9dcf48469ab6e464a231157d5e5c8cd23293b8c11279df911ccd591536aab593b3ab9e2507bb87db5ed7de55228cea99434d201c9d53be
|
7
|
+
data.tar.gz: 302b99956194d9fd94c47fa60a9aa5198b82fe7052b74f88fcdd87dc8945dd2c44644b217e6c81738df55c71f35804c98f3f4646c940b56a5195ab9cce680af3
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module DenormalizeFields
|
4
|
+
module AssociationExtension
|
5
|
+
OPTION = :denormalize
|
6
|
+
|
7
|
+
def self.valid_options
|
8
|
+
[OPTION]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.build(model, association)
|
12
|
+
return unless options = association.options[OPTION]
|
13
|
+
|
14
|
+
DenormalizeFields.denormalize(
|
15
|
+
fields: options[:fields],
|
16
|
+
from: association.active_record,
|
17
|
+
onto: association.name,
|
18
|
+
prefix: options[:prefix],
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
ActiveRecord::Associations::Builder::Association.extensions <<
|
25
|
+
DenormalizeFields::AssociationExtension
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: denormalize_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janosch Müller
|
@@ -115,6 +115,7 @@ extensions: []
|
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
117
|
- lib/denormalize_fields.rb
|
118
|
+
- lib/denormalize_fields/association_extension.rb
|
118
119
|
- lib/denormalize_fields/version.rb
|
119
120
|
homepage: https://www.github.com/jaynetics/denormalize_fields
|
120
121
|
licenses:
|