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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 165e1a192514f78811d5e4dc661da1dfd8971fa7
4
- data.tar.gz: d5ed75bd800f761fe66247c9a076e7edc98b466a
3
+ metadata.gz: 8327f5c943684bbe0695537924ef931c8fd77ec2
4
+ data.tar.gz: 9505bb35ee376290662cee35a8b672d777c736a0
5
5
  SHA512:
6
- metadata.gz: bd209021677c3b3965e2797bc03431ef5363ce845bd1ed52dad51eaf4fd10051621897c8be128196ee0676cce2c639d57810e0f5a24c7ca785898fdab231a925
7
- data.tar.gz: cb08aec84ade3e2277a3784231978c9708419c54b386786104642cb985dd9d0c0c551a7914dce41e06c794edca11af5903ac1707334eb5346ce72218aca4307e
6
+ metadata.gz: f359cfff35e6aab4fdc1aacc700d0bc4bf03a579e93120a6486114ff8706087c65de49e8a1bd24c888a2c0d4402be3295bbd7bd07a96006dcaa3367ee459e260
7
+ data.tar.gz: 0a2786ace0504bdb34047ada0e0009dad2bf7f2d967e3236d917f64f49b27ae878b4948175f153a490a35b6aa1ec456a8a97caa24298234b5b3d8c065135dffc
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ActiveDynamic
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/active_dynamic.svg)](https://badge.fury.io/rb/active_dynamic)
4
+ [![Code Climate](https://codeclimate.com/github/koss-lebedev/active_dynamic/badges/gpa.svg)](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
 
@@ -1,3 +1,3 @@
1
1
  module ActiveDynamic
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
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.1.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-03 00:00:00.000000000 Z
11
+ date: 2017-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord