dynamo_record 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamo_record/fields.rb +1 -1
- data/lib/dynamo_record/version.rb +1 -1
- data/spec/dynamo_record/fields_spec.rb +11 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f4b800863e658f88af3a6ea20bd0223e945daca
|
4
|
+
data.tar.gz: 12b65d2ea96d315e2fdd73772ed26065eba00ea2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b77f201f8e17c176765069f55f4ae716d63442096bf1f38e81e6175d40c559ea79219cbcef2f4452120a4c9edf7a2a7a38ac798a78b1e73eddc8db8203d28fbc
|
7
|
+
data.tar.gz: b1387a034395a98388b9a8bf5713c0075ac28dfca2c127ec87219b8965e50a101a26f5fee39db19c9a566f252b2cf6abca5f57f5d61ce4deb4fcf9e2cc06047c
|
data/lib/dynamo_record/fields.rb
CHANGED
@@ -13,7 +13,7 @@ module DynamoRecord
|
|
13
13
|
module ClassMethods
|
14
14
|
def field(name, type = :string, opts = {})
|
15
15
|
named = name.to_s
|
16
|
-
self.attributes
|
16
|
+
self.attributes.merge!(name => {type: type, options: opts})
|
17
17
|
|
18
18
|
define_method("#{named}=") { |value| write_attribute(named, value) }
|
19
19
|
define_method("#{name}") { read_attribute(named) }
|
@@ -8,7 +8,15 @@ RSpec.describe DynamoRecord::Fields do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'accepts adding fields' do
|
11
|
-
|
11
|
+
class Employee
|
12
|
+
include DynamoRecord::Document
|
13
|
+
|
14
|
+
field :first_name, :string
|
15
|
+
field :last_name, :string
|
16
|
+
end
|
17
|
+
expect(Employee.attributes).to eq({id: {type: :string, options: {}},
|
18
|
+
first_name: {type: :string, options: {}},
|
19
|
+
last_name: {type: :string, options: {}}})
|
12
20
|
end
|
13
21
|
|
14
22
|
it 'accepts adding fields with index' do
|
@@ -18,7 +26,8 @@ RSpec.describe DynamoRecord::Fields do
|
|
18
26
|
field :name, :string, index: true
|
19
27
|
end
|
20
28
|
|
21
|
-
expect(City.attributes).to eq({
|
29
|
+
expect(City.attributes).to eq({id: {type: :string, options: {}},
|
30
|
+
name: {type: :string, options: {index: true}}})
|
22
31
|
end
|
23
32
|
|
24
33
|
it 'initializes with field values' do
|