active_dynamic 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e209fa9cc3fc6975f796cdf16604f243035548b5
4
- data.tar.gz: 6a86403d63d1839c8bbcee14e428c38d2e0a1065
3
+ metadata.gz: 8330d30761f09e9432dd1526f9a0e93abe7e79ee
4
+ data.tar.gz: 3b423c2a7a08aeca41fdecdaf395a4a28858d10b
5
5
  SHA512:
6
- metadata.gz: e1d0d2ac25933e40b50f604fe667fc5ae8a09da7afa139c534f1ce8e74f02bb11fa0f0bdd4206c4a46ee5838159d64107510c15177a6a0c4d6f22f41b81a48fb
7
- data.tar.gz: b861719d552382ed4bd3a4fa1d12778b62266feb0ceabbba89d0f33865b9ea352ab892700ce5020318d293acb8fd89c7a67837924c649a567e0b855f0ef9d275
6
+ metadata.gz: d056f3d4d289a5028934d3930c20aa21c3cc4af30688de0ee6cb2ddd18713343a20f0a05c5b3c7fc8ee8210b07547e3176110b5330d9bdc6e1e5da05a6caf1e9
7
+ data.tar.gz: 6b5087d446235b4ce70217b2df033db18a6457e838bea33217d78787837e6152a58fe206d0d93f9fbc03bf9248cbec6af3495c4aca82b843ca273dac57509c35
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- *.gem
10
+ *.gem
11
+ *.log
@@ -4,9 +4,7 @@ module ActiveDynamic
4
4
 
5
5
  included do
6
6
  has_many :active_dynamic_attributes, class_name: ActiveDynamic::Attribute, autosave: true, as: :customizable
7
-
8
7
  before_save :save_dynamic_attributes
9
- after_find :load_dynamic_attributes
10
8
  end
11
9
 
12
10
  def dynamic_attributes
@@ -17,15 +15,28 @@ module ActiveDynamic
17
15
  end
18
16
  end
19
17
 
20
- private
18
+ def dynamic_attributes_loaded?
19
+ @dynamic_attributes_loaded ||= false
20
+ end
21
+
22
+ def respond_to?(method_name, include_private = false)
23
+ unless dynamic_attributes_loaded?
24
+ load_dynamic_attributes
25
+ end
26
+ dynamic_attributes.find { |attr| attr.name == method_name.to_s.gsub(/=/, '') }.present? || super
27
+ end
21
28
 
22
- # use internal ActiveModel callback to generate accessors for dynamic attributes
23
- # before attributes get assigned
24
- def initialize_internals_callback
25
- load_dynamic_attributes
26
- super
29
+ def method_missing(method_name, *arguments, &block)
30
+ if dynamic_attributes_loaded?
31
+ super
32
+ else
33
+ load_dynamic_attributes
34
+ send(method_name, *arguments, &block)
35
+ end
27
36
  end
28
37
 
38
+ private
39
+
29
40
  def generate_accessors(fields)
30
41
  fields.each do |field|
31
42
 
@@ -58,6 +69,7 @@ module ActiveDynamic
58
69
  end
59
70
 
60
71
  generate_accessors dynamic_attributes
72
+ @dynamic_attributes_loaded = true
61
73
  end
62
74
 
63
75
  def save_dynamic_attributes
@@ -1,3 +1,3 @@
1
1
  module ActiveDynamic
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
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.5.2
4
+ version: 0.5.3
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-24 00:00:00.000000000 Z
11
+ date: 2017-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord