cistern 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cistern/attributes.rb +14 -4
- data/lib/cistern/version.rb +1 -1
- data/spec/model_spec.rb +17 -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: 51ecc36c328ba3a9a404a952c76144db023edfa3
|
4
|
+
data.tar.gz: 0a7a965f9b3a3c37b78cd78802456537e251e3b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f668e16c9431a22a14fcc628872b337835c9873fde7e75fc9099f6eb257d4c5cf30657e4b0513efad785d567be9ef2650d29db5d2acabc9d2dd6cdc232e4845f
|
7
|
+
data.tar.gz: ecf04f9577df53a188eb09496d34c01a6a8696af93377a5ef45982afe6f63d5f96ba1af4c1d80d4cf585794c53c600524b42c6d8cc9a8b9de000289f3f85707f
|
data/lib/cistern/attributes.rb
CHANGED
@@ -173,11 +173,21 @@ module Cistern::Attributes
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def identity
|
176
|
-
|
176
|
+
key = self.class.instance_variable_get('@identity')
|
177
|
+
|
178
|
+
if key
|
179
|
+
public_send(key)
|
180
|
+
end
|
177
181
|
end
|
178
182
|
|
179
183
|
def identity=(new_identity)
|
180
|
-
|
184
|
+
key = self.class.instance_variable_get('@identity')
|
185
|
+
|
186
|
+
if key
|
187
|
+
public_send("#{key}=", new_identity)
|
188
|
+
else
|
189
|
+
raise ArgumentError, "Identity not specified"
|
190
|
+
end
|
181
191
|
end
|
182
192
|
|
183
193
|
def merge_attributes(new_attributes = {})
|
@@ -222,7 +232,7 @@ module Cistern::Attributes
|
|
222
232
|
end
|
223
233
|
|
224
234
|
def new_record?
|
225
|
-
|
235
|
+
identity.nil?
|
226
236
|
end
|
227
237
|
|
228
238
|
# check that the attributes specified in args exist and is not nil
|
@@ -257,7 +267,7 @@ module Cistern::Attributes
|
|
257
267
|
protected
|
258
268
|
|
259
269
|
def missing_attributes(args)
|
260
|
-
([:service] | args).select{|arg| send("#{arg}").nil?}
|
270
|
+
([:service] | args).select { |arg| send("#{arg}").nil? }
|
261
271
|
end
|
262
272
|
|
263
273
|
def changed!(attribute, from, to)
|
data/lib/cistern/version.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -20,6 +20,23 @@ describe "Cistern::Model" do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
context "#new_record?" do
|
24
|
+
it "does not require identity" do
|
25
|
+
identity_less = Class.new(Sample::Model)
|
26
|
+
|
27
|
+
expect(identity_less.new.new_record?).to eq(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "is false if identity is set" do
|
31
|
+
identity_full = Class.new(Sample::Model) {
|
32
|
+
identity :id
|
33
|
+
}
|
34
|
+
|
35
|
+
expect(identity_full.new.new_record?).to eq(true)
|
36
|
+
expect(identity_full.new(id: 1).new_record?).to eq(false)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
23
40
|
it "should set singular resource service method" do
|
24
41
|
class ModelService < Cistern::Service
|
25
42
|
end
|
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.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: API client framework extracted from Fog
|
14
14
|
email:
|