entity_store 0.2.14 → 0.2.15

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: da47c343082dee8f07abfc0c3dd8a0f57418b4cd
4
- data.tar.gz: 549266a31901d09c77a34839d6f5d8ddf8708364
3
+ metadata.gz: f6957074ac4594c6b4a1068ad4131fab670763a0
4
+ data.tar.gz: 7a975bf8fc65eacf1a15914d973371a1267f0295
5
5
  SHA512:
6
- metadata.gz: 2b7a028a7f73a67ef28a09ccdf009e8ba8bcd02f34c8c31832c26d81a9ebbc8323dffe93854e06178b1851423c77f94e00654a489f8fa8af76883ce6cd90275d
7
- data.tar.gz: 4317c2c625b7ffb233f1b6e1c6d7f04a9170c0a94d2245c6270e51afcd3887357dd0798679671662200d36ec223af92c63692d102d6022e478f0b0b6c6616307
6
+ metadata.gz: 9865c283a793d09f4d22b57fe4c0bb40c2d8b58b3049708692050539856663e252e19d63e0fed878967ce2d56977328606e72dcadc3fb8b0e60e655068427b1d
7
+ data.tar.gz: d3ce7d96186648e7f44152be97694393d4b783f3a1c0ebcca08feac5c4aee73dfb50dc6f6ce4cca6e90d84bb753b25dee54c0c061a1619ca52c9766a1a3968a9
@@ -2,7 +2,16 @@ module EntityStore
2
2
  module HashSerialization
3
3
 
4
4
  def initialize(attr={})
5
- attr.each { |item| send("#{item[0]}=", item[1]) if respond_to?("#{item[0]}=") }
5
+ values = attr
6
+ values = values.attributes if values.respond_to? :attributes
7
+
8
+ unless values.is_a? Hash
9
+ raise "Do not know how to create #{self.class} from #{attr.class}"
10
+ end
11
+
12
+ values.each do |key, value|
13
+ send("#{key}=", value) if respond_to?("#{key}=")
14
+ end
6
15
  end
7
16
 
8
17
  # Public - generate attributes hash
@@ -37,4 +46,4 @@ module EntityStore
37
46
  end
38
47
 
39
48
  end
40
- end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module EntityStore
2
- VERSION = "0.2.14".freeze
3
- end
2
+ VERSION = "0.2.15".freeze
3
+ end
@@ -116,6 +116,38 @@ describe Entity do
116
116
  end
117
117
  end
118
118
  end
119
+
120
+ context "when initialize with entity" do
121
+ subject { DummyEntity.new(@entity) }
122
+
123
+ it "should set simple attributes" do
124
+ subject.id.should eq(@entity.id)
125
+ end
126
+
127
+ it "should set entity value array attributes" do
128
+ actual = subject
129
+ actual.things.count.should eq(@entity.things.count)
130
+ actual.things.each_with_index do |item, i|
131
+ item.should eq(@entity.things[i])
132
+ end
133
+ end
134
+
135
+ it "should set entity value dictionary attributes" do
136
+ actual = subject
137
+ actual.other_things_dictionary.keys.count.should eq(@entity.other_things_dictionary.keys.count)
138
+ actual.other_things_dictionary.each_pair do |k,v|
139
+ v.should eq(@entity.other_things_dictionary[k])
140
+ end
141
+ end
142
+ end
143
+
144
+ context "when initialize with something unknown" do
145
+ subject { DummyEntity.new(1) }
146
+
147
+ it "should raise a readable error" do
148
+ expect { subject }.to raise_error(RuntimeError, "Do not know how to create DummyEntity from Fixnum")
149
+ end
150
+ end
119
151
  end
120
152
 
121
153
  describe ".entity_value_array_attribute" do
@@ -251,4 +283,4 @@ describe Entity do
251
283
  end
252
284
  end
253
285
 
254
- end
286
+ end
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.2.14
4
+ version: 0.2.15
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-04-03 00:00:00.000000000 Z
11
+ date: 2014-04-24 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: []