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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a2797ca8edb773a77fe40604024aeca97df9880
4
- data.tar.gz: 4bfd89a74eef61fdd0cca096a01465235a40009f
3
+ metadata.gz: 8d74b41f098f699d93b5d42a8cc0915ac2169162
4
+ data.tar.gz: 1171cb486f3155fb05faf470bad810349d3a7a36
5
5
  SHA512:
6
- metadata.gz: bab52f2a7c09673e54e943da2ada9cacdf8684ca0b3b419c415a8fbc031f5090a9c378ba366adeee9d662770a744975b6732b6715dbc03baccbc0bde93d3fa23
7
- data.tar.gz: 805ab1b15511ada7e048f0ebdea1f7e1ca8ab15bfdd3cf7fca417c8662eeef7e4cfd5851381491cc432fcb21f9ece6bd033bd2ea150634195307578b2ec1ab33
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.3.0...HEAD)
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
 
@@ -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(name, options = {})
63
- @identity = name
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.instance_variable_get('@identity')
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.instance_variable_get('@identity')
188
+ key = self.class.identity
184
189
 
185
190
  if key
186
191
  public_send("#{key}=", new_identity)
@@ -1,3 +1,3 @@
1
1
  module Cistern
2
- VERSION = '2.4.0'
2
+ VERSION = '2.4.1'
3
3
  end
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.0
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 00:00:00.000000000 Z
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: