cistern 2.4.0 → 2.4.1
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/CHANGELOG.md +8 -1
- data/lib/cistern/attributes.rb +10 -5
- data/lib/cistern/version.rb +1 -1
- data/spec/model_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d74b41f098f699d93b5d42a8cc0915ac2169162
|
4
|
+
data.tar.gz: 1171cb486f3155fb05faf470bad810349d3a7a36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 697575fd1b7a88143f1c6ed754ed38fc1813584e2bf22faa324499f3eb8ae503cb02413c799aa14bafc5f9b97af44c721aaf03cafe9ae9502af78337edffbb60
|
7
|
+
data.tar.gz: 285daf44f8c9048ed45321c9c270c2be04c0a5d181ef867c8aee5a1a421b81e0ce231e3d535c522ba9f9e4f9ae54d93bba15ccda689306a3c9651af1414128c0
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,14 @@
|
|
2
2
|
|
3
3
|
## [Unreleased](https://github.com/lanej/cistern/tree/HEAD)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/lanej/cistern/compare/v2.
|
5
|
+
[Full Changelog](https://github.com/lanej/cistern/compare/v2.4.0...HEAD)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- fix\(attributes\): child classes inherit parent identity [\#64](https://github.com/lanej/cistern/pull/64) ([lanej](https://github.com/lanej))
|
10
|
+
|
11
|
+
## [v2.4.0](https://github.com/lanej/cistern/tree/v2.4.0) (2016-07-11)
|
12
|
+
[Full Changelog](https://github.com/lanej/cistern/compare/v2.3.0...v2.4.0)
|
6
13
|
|
7
14
|
**Implemented enhancements:**
|
8
15
|
|
data/lib/cistern/attributes.rb
CHANGED
@@ -57,11 +57,12 @@ module Cistern::Attributes
|
|
57
57
|
|
58
58
|
define_attribute_reader(name_sym, options)
|
59
59
|
define_attribute_writer(name_sym, options)
|
60
|
+
|
61
|
+
name_sym
|
60
62
|
end
|
61
63
|
|
62
|
-
def identity(
|
63
|
-
@identity =
|
64
|
-
attribute(name, options)
|
64
|
+
def identity(*args)
|
65
|
+
args.any? ? @identity = attribute(*args) : (@identity ||= parent_identity)
|
65
66
|
end
|
66
67
|
|
67
68
|
def ignore_attributes(*args)
|
@@ -117,6 +118,10 @@ module Cistern::Attributes
|
|
117
118
|
def parent_attributes
|
118
119
|
superclass && superclass.respond_to?(:attributes) && superclass.attributes.dup
|
119
120
|
end
|
121
|
+
|
122
|
+
def parent_identity
|
123
|
+
superclass && superclass.respond_to?(:identity) && superclass.identity
|
124
|
+
end
|
120
125
|
end
|
121
126
|
|
122
127
|
module InstanceMethods
|
@@ -174,13 +179,13 @@ module Cistern::Attributes
|
|
174
179
|
end
|
175
180
|
|
176
181
|
def identity
|
177
|
-
key = self.class.
|
182
|
+
key = self.class.identity
|
178
183
|
|
179
184
|
public_send(key) if key
|
180
185
|
end
|
181
186
|
|
182
187
|
def identity=(new_identity)
|
183
|
-
key = self.class.
|
188
|
+
key = self.class.identity
|
184
189
|
|
185
190
|
if key
|
186
191
|
public_send("#{key}=", new_identity)
|
data/lib/cistern/version.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -14,7 +14,29 @@ describe 'Cistern::Model' do
|
|
14
14
|
expect(parent.attributes.keys).to contain_exactly(:parent)
|
15
15
|
expect(child.attributes.keys).to contain_exactly(:parent, :child)
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'provides the child with the identity of the parent' do
|
19
|
+
parent = Class.new(Sample::Model) do
|
20
|
+
identity :name
|
21
|
+
attribute :parent
|
22
|
+
end
|
23
|
+
|
24
|
+
child = Class.new(parent) do
|
25
|
+
attribute :child
|
26
|
+
end
|
27
|
+
|
28
|
+
expect(parent.identity).to eq(:name)
|
29
|
+
expect(child.identity).to eq(:name)
|
30
|
+
expect(child.new).to respond_to(:name)
|
31
|
+
|
32
|
+
girl = child.new
|
33
|
+
|
34
|
+
expect {
|
35
|
+
girl.name = 'lady'
|
36
|
+
}.to change(girl, :identity).to('lady')
|
37
|
+
end
|
17
38
|
end
|
39
|
+
|
18
40
|
describe '#update' do
|
19
41
|
class UpdateSpec < Sample::Model
|
20
42
|
identity :id
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cistern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: API client framework extracted from Fog
|
14
14
|
email:
|