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 +4 -4
- data/lib/entity_components.rb +40 -9
- data/lib/entity_components/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f10af79244a764ee1246039504a57dfc30fc124f
|
4
|
+
data.tar.gz: c732aa8db65112d24a634b9e10e68afc1ecd8bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf1efd9b5c813205ed5b35e4a3e93321b685165a7eb1e4a43cd38204fc7bca5510e960cb8a3dd8f4f0f9ce154691e324e19ef6e55f7421ca040ebfb422f7d22d
|
7
|
+
data.tar.gz: 495153230138858c8bffa4484ae5628168207c106e17fb0276d5850097dbccf8428d9457e1fb5b5c267e482127d7cb1a9363a42e3e9f06ac0a42e717cbf91260
|
data/lib/entity_components.rb
CHANGED
@@ -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
|
+
|
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.
|
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-
|
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.
|
109
|
+
rubygems_version: 2.2.2
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Simple components for entities in Rails
|