active_dynamic 0.1.0 → 0.2.0
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 +3 -0
- data/lib/active_dynamic/has_dynamic_attributes.rb +7 -6
- data/lib/active_dynamic/version.rb +1 -1
- 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: 8327f5c943684bbe0695537924ef931c8fd77ec2
|
|
4
|
+
data.tar.gz: 9505bb35ee376290662cee35a8b672d777c736a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f359cfff35e6aab4fdc1aacc700d0bc4bf03a579e93120a6486114ff8706087c65de49e8a1bd24c888a2c0d4402be3295bbd7bd07a96006dcaa3367ee459e260
|
|
7
|
+
data.tar.gz: 0a2786ace0504bdb34047ada0e0009dad2bf7f2d967e3236d917f64f49b27ae878b4948175f153a490a35b6aa1ec456a8a97caa24298234b5b3d8c065135dffc
|
data/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# ActiveDynamic
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/active_dynamic)
|
|
4
|
+
[](https://codeclimate.com/github/koss-lebedev/active_dynamic)
|
|
5
|
+
|
|
3
6
|
ActiveDynamic allows to dynamically add properties to your ActiveRecord models and
|
|
4
7
|
work with them as regular properties.
|
|
5
8
|
To see this in practice, check out the demo application available at [https://github.com/koss-lebedev/active_dynamic_demo](https://github.com/koss-lebedev/active_dynamic_demo)
|
|
@@ -5,15 +5,9 @@ module ActiveDynamic
|
|
|
5
5
|
included do
|
|
6
6
|
has_many :active_dynamic_attributes, class_name: ActiveDynamic::Attribute, autosave: true, as: :customizable
|
|
7
7
|
|
|
8
|
-
after_initialize :load_dynamic_attributes
|
|
9
8
|
before_save :save_dynamic_attributes
|
|
10
9
|
end
|
|
11
10
|
|
|
12
|
-
# def initialize(*args)
|
|
13
|
-
# super
|
|
14
|
-
# load_dynamic_attributes
|
|
15
|
-
# end
|
|
16
|
-
|
|
17
11
|
def dynamic_attributes
|
|
18
12
|
if persisted?
|
|
19
13
|
active_dynamic_attributes.order(:created_at)
|
|
@@ -28,6 +22,13 @@ module ActiveDynamic
|
|
|
28
22
|
|
|
29
23
|
private
|
|
30
24
|
|
|
25
|
+
# use internal ActiveModel callback to generate accessors for dynamic attributes
|
|
26
|
+
# before attributes get assigned
|
|
27
|
+
def initialize_internals_callback
|
|
28
|
+
load_dynamic_attributes
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
31
32
|
def generate_accessors(fields)
|
|
32
33
|
fields.map(&:name).each do |field|
|
|
33
34
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_dynamic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Constantine Lebedev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-02-
|
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|