entity_components 0.1.0 → 0.1.1

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: f40b3f2157a69a8112245a1b28dec8b1adfcb74a
4
- data.tar.gz: 92a339ee779ece381042bc94a2a60818e1239783
3
+ metadata.gz: f10af79244a764ee1246039504a57dfc30fc124f
4
+ data.tar.gz: c732aa8db65112d24a634b9e10e68afc1ecd8bbf
5
5
  SHA512:
6
- metadata.gz: 013649bb66b7bee0aaf40367778d2bfaff16a03d5b014a0eefa48164ab3f536045cadf06493ac5a9b5b2cd90fadb0989c50ecd7099f5ff93389b9da64bd653b0
7
- data.tar.gz: ef5c821b78eae3b8e3f2d12fc60ef23e81fd22da080a9e341a7badd548a2618c44ccfded1d195d709030b7e504135782d4523a9476f897814efb611b6529283a
6
+ metadata.gz: bf1efd9b5c813205ed5b35e4a3e93321b685165a7eb1e4a43cd38204fc7bca5510e960cb8a3dd8f4f0f9ce154691e324e19ef6e55f7421ca040ebfb422f7d22d
7
+ data.tar.gz: 495153230138858c8bffa4484ae5628168207c106e17fb0276d5850097dbccf8428d9457e1fb5b5c267e482127d7cb1a9363a42e3e9f06ac0a42e717cbf91260
@@ -3,17 +3,9 @@ require 'entity_components/railtie' if defined? Rails
3
3
 
4
4
  require 'active_support/concern'
5
5
 
6
- module EntityComponents
6
+ module EntityComponents::Hooks
7
7
  extend ActiveSupport::Concern
8
8
 
9
- included do
10
- serialize :components, Array
11
- serialize :values
12
-
13
- after_initialize :initialize_components
14
- before_validation :serialize_components
15
- end
16
-
17
9
  def initialize_components
18
10
  components.each do |c|
19
11
  variable_name = "@#{c}".to_sym
@@ -34,3 +26,42 @@ module EntityComponents
34
26
  end
35
27
  end
36
28
  end
29
+
30
+ module EntityComponents::ActiveRecord
31
+ extend ActiveSupport::Concern
32
+
33
+ include EntityComponents::Hooks
34
+
35
+ included do
36
+ serialize :components, Array
37
+ serialize :values
38
+
39
+ after_initialize :initialize_components
40
+ before_validation :serialize_components
41
+ end
42
+ end
43
+
44
+ module EntityComponents::NoBrainer
45
+ extend ActiveSupport::Concern
46
+
47
+ include EntityComponents::Hooks
48
+
49
+ included do
50
+ after_initialize :initialize_components
51
+ before_validation :serialize_components
52
+
53
+ field :values, type: Hash
54
+ field :components, type: Array
55
+ end
56
+
57
+ def _update_only_changed_attrs(*args)
58
+ serialize_components
59
+ super
60
+ end
61
+
62
+ def _create(*args)
63
+ serialize_components
64
+ super
65
+ end
66
+ end
67
+
@@ -1,3 +1,3 @@
1
1
  module EntityComponents
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tinco Andringa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-07 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.5.1
109
+ rubygems_version: 2.2.2
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Simple components for entities in Rails