entity_store 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/entity_store/attributes.rb +13 -9
- data/lib/entity_store/hash_serialization.rb +3 -0
- data/lib/entity_store/version.rb +1 -1
- data/spec/entity_store/entity_spec.rb +12 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a15a515aaab833170cd1874dd0ed2bcb878747d6
|
4
|
+
data.tar.gz: c5f62d569ebace43e4ac6f3f18de1ede780b1c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af5c80820dc57d1904b6d5f64d4742004a851fc5782b12a33ed56ece03a528d6fd55cc96644ff929ed1ded844492eedc11e9d9dae9578992fa6873a542a722b4
|
7
|
+
data.tar.gz: 06d3cef2139723f728274332e512a2b0e8f30686421dfa7825d3816d6eaf6dce1ac598bb204c784c4295412e651556fd1fca5b01a0ceb8b82bcc52d60cf2435f
|
@@ -26,21 +26,25 @@ module EntityStore
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def entity_value_array_attribute name, klass
|
29
|
-
|
30
|
-
instance_variable_get("@_#{name}") || instance_variable_set("@_#{name}", [])
|
31
|
-
}
|
29
|
+
variable_name = "@_#{name}".to_sym
|
32
30
|
|
33
|
-
define_method(
|
34
|
-
|
35
|
-
|
31
|
+
define_method(name) do
|
32
|
+
instance_variable_get(variable_name) || instance_variable_set(variable_name, [])
|
33
|
+
end
|
34
|
+
|
35
|
+
define_method("#{name}=") do |values|
|
36
|
+
mapped_values = values.map do |value|
|
37
|
+
case value
|
36
38
|
when Hash
|
37
|
-
|
39
|
+
klass.new(value)
|
38
40
|
when klass
|
39
|
-
|
41
|
+
value
|
40
42
|
else
|
41
|
-
raise ArgumentError.new("#{
|
43
|
+
raise ArgumentError.new("#{value.class} not supported. Expecting #{klass.name}")
|
42
44
|
end
|
43
45
|
end
|
46
|
+
|
47
|
+
instance_variable_set(variable_name, mapped_values)
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
data/lib/entity_store/version.rb
CHANGED
@@ -131,6 +131,18 @@ describe Entity do
|
|
131
131
|
expect { entity.things = items }.to raise_error(ArgumentError)
|
132
132
|
end
|
133
133
|
end
|
134
|
+
context "when already populated" do
|
135
|
+
let(:items) { [ ThingEntityValue.new(name: random_string), ThingEntityValue.new(name: random_string)] }
|
136
|
+
|
137
|
+
before(:each) do
|
138
|
+
entity.things = [{ name: random_string }, { name: random_string }]
|
139
|
+
entity.things = items
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should replace the contents" do
|
143
|
+
entity.things.should eq(items)
|
144
|
+
end
|
145
|
+
end
|
134
146
|
end
|
135
147
|
|
136
148
|
describe "getter" do
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: entity_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bird
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bson_ext
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hatchet
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.2'
|
55
55
|
description: Event sourced entity store with a replaceable body
|
@@ -96,12 +96,12 @@ require_paths:
|
|
96
96
|
- lib
|
97
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - '>='
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|