hexx-entities 0.1.1 → 0.2.0
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 +4 -4
- data/Guardfile +3 -3
- data/hexx-entities.gemspec +1 -1
- data/lib/hexx-entities.rb +11 -7
- data/lib/{hexx/entities → hexx-entities}/base.rb +0 -0
- data/lib/{hexx/entities → hexx-entities}/part.rb +9 -4
- data/lib/{hexx/entities → hexx-entities}/uuid.rb +0 -0
- data/lib/{hexx/entities → hexx-entities}/uuids.rb +0 -0
- data/lib/{hexx/entities → hexx-entities}/version.rb +1 -1
- data/spec/tests/part_spec.rb +5 -2
- metadata +6 -7
- data/lib/hexx/entities.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04667c21ab81ba4a9e2c69c734d0eb1da0f5259e
|
4
|
+
data.tar.gz: fc9d3d1826fb1751813c145128ce5f1b88a182e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b3c8514ef9a5f8717ec931d21a28da63cfa86ea5da2b1609195913aaa3e7de00e06b3522f3f41a7bac56548af1d42597dd65f0ff59d24a7065ac3060ec481f1
|
7
|
+
data.tar.gz: 0863e2cc356a59c2f74f731f1c3fbc69bbf0e8ccb47799c7245c06be63abfe4343a9955b4de46e347ef232f3784a3e176f42dc7166baced3cd6814094405a44e
|
data/Guardfile
CHANGED
@@ -4,11 +4,11 @@ guard :rspec, cmd: "bundle exec rspec" do
|
|
4
4
|
|
5
5
|
watch(%r{^spec/tests/.+_spec\.rb$})
|
6
6
|
|
7
|
-
watch(%r{^lib/hexx
|
7
|
+
watch(%r{^lib/hexx-entities/(.+)\.rb}) do |m|
|
8
8
|
"spec/tests/#{ m[1] }_spec.rb"
|
9
9
|
end
|
10
10
|
|
11
|
-
watch(
|
12
|
-
watch("spec/spec_helper.rb")
|
11
|
+
watch("lib/hexx-entities.rb") { "spec" }
|
12
|
+
watch("spec/spec_helper.rb") { "spec" }
|
13
13
|
|
14
14
|
end # guard :rspec
|
data/hexx-entities.gemspec
CHANGED
data/lib/hexx-entities.rb
CHANGED
@@ -4,15 +4,19 @@ require "attestor" # for validations
|
|
4
4
|
require "eigindir" # for attributes
|
5
5
|
require "securerandom" # for uuids
|
6
6
|
|
7
|
-
#
|
7
|
+
# Shared namespace for the hexx collection of modules
|
8
8
|
#
|
9
|
-
# @author Andrew Kozin <Andrew.Kozin@gmail.com>
|
10
9
|
module Hexx
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
# Module Entities provides a base class for domain entities
|
12
|
+
#
|
13
|
+
module Entities
|
14
|
+
|
15
|
+
require_relative "hexx-entities/part"
|
16
|
+
require_relative "hexx-entities/uuid"
|
17
|
+
require_relative "hexx-entities/uuids"
|
18
|
+
require_relative "hexx-entities/base"
|
19
|
+
|
20
|
+
end # module Entities
|
17
21
|
|
18
22
|
end # module Hexx
|
File without changes
|
@@ -46,10 +46,15 @@ module Hexx::Entities
|
|
46
46
|
#
|
47
47
|
# @return [Hash]
|
48
48
|
def serialize
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
attributes.map { |key, value| [key, serialize__(value)] }.to_h
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def serialize__(value)
|
55
|
+
return value.serialize if value.respond_to? :serialize
|
56
|
+
return value.map { |item| serialize__(item) } if value.is_a? Array
|
57
|
+
value
|
53
58
|
end
|
54
59
|
|
55
60
|
end # class Part
|
File without changes
|
File without changes
|
data/spec/tests/part_spec.rb
CHANGED
@@ -39,15 +39,18 @@ describe Hexx::Entities::Part do
|
|
39
39
|
|
40
40
|
before { klass.attribute :foo }
|
41
41
|
before { klass.attribute :bar }
|
42
|
+
before { klass.attribute :qux }
|
42
43
|
|
43
44
|
let(:bar) { double }
|
44
45
|
let(:baz) { double serialize: { baz: :baz } }
|
46
|
+
let(:qux) { [bar, baz] }
|
45
47
|
let(:uuids) { [SecureRandom.uuid] }
|
46
48
|
|
47
|
-
subject(:entity) { klass.new(foo: bar, bar: baz) }
|
49
|
+
subject(:entity) { klass.new(foo: bar, bar: baz, qux: qux) }
|
48
50
|
|
49
51
|
it "returns a nested hash" do
|
50
|
-
expect(entity.serialize)
|
52
|
+
expect(entity.serialize)
|
53
|
+
.to eq(foo: bar, bar: { baz: :baz }, qux: [bar, { baz: :baz }])
|
51
54
|
end
|
52
55
|
|
53
56
|
end # describe #to_hash
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexx-entities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin
|
@@ -85,12 +85,11 @@ files:
|
|
85
85
|
- config/metrics/yardstick.yml
|
86
86
|
- hexx-entities.gemspec
|
87
87
|
- lib/hexx-entities.rb
|
88
|
-
- lib/hexx/
|
89
|
-
- lib/hexx
|
90
|
-
- lib/hexx
|
91
|
-
- lib/hexx
|
92
|
-
- lib/hexx
|
93
|
-
- lib/hexx/entities/version.rb
|
88
|
+
- lib/hexx-entities/base.rb
|
89
|
+
- lib/hexx-entities/part.rb
|
90
|
+
- lib/hexx-entities/uuid.rb
|
91
|
+
- lib/hexx-entities/uuids.rb
|
92
|
+
- lib/hexx-entities/version.rb
|
94
93
|
- spec/spec_helper.rb
|
95
94
|
- spec/tests/base_spec.rb
|
96
95
|
- spec/tests/part_spec.rb
|
data/lib/hexx/entities.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Hexx
|
4
|
-
|
5
|
-
# Module Entities provides a base class for domain entities
|
6
|
-
#
|
7
|
-
# @example (see Hexx::Entities::Base)
|
8
|
-
#
|
9
|
-
# @author Andrew Kozin <Andrew.Kozin@gmail.com>
|
10
|
-
module Entities
|
11
|
-
|
12
|
-
end # module Entities
|
13
|
-
|
14
|
-
end # module Hexx
|