cistern 0.5.10 → 0.6.0
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 +1 -1
- data/lib/cistern/version.rb +1 -1
- data/spec/model_spec.rb +9 -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: 7013053b6babdbcbc398b16bb018cc889cfd01c7
|
4
|
+
data.tar.gz: 81c10f424574419b9bf216ea4a3fec9ec9327b23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9238df8c51907706409456fb98a7b1181610b7c761efee3f8d0bc427fb498d1fec4e21a1cbbab71e9619dad62aa33df0bd448b449c9706a5a5aa8bc8c1e55780
|
7
|
+
data.tar.gz: a162d7a75411925f030e30070fb8ec28c1de78eaa10a897f37ebc8cdd9dee818e47b4d1233701f9061417da3b7d6292f5c39c9c5a859c9b9680ac3d3a2e6efa4
|
data/lib/cistern/attributes.rb
CHANGED
@@ -80,7 +80,7 @@ module Cistern::Attributes
|
|
80
80
|
# record the attribute was accessed
|
81
81
|
self.class.attributes[name.to_s.to_sym][:coverage_hits] += 1 rescue nil
|
82
82
|
|
83
|
-
attributes
|
83
|
+
attributes.fetch(name.to_s.to_sym, options[:default])
|
84
84
|
end unless self.instance_methods.include?(name)
|
85
85
|
|
86
86
|
if options[:type] == :boolean
|
data/lib/cistern/version.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -33,6 +33,7 @@ describe "Cistern::Model" do
|
|
33
33
|
attribute :squash
|
34
34
|
attribute :vegetable, aliases: "squash"
|
35
35
|
attribute :custom, parser: lambda { |v, _| "X!#{v}" }
|
36
|
+
attribute :default, default: "im a squash"
|
36
37
|
|
37
38
|
attribute :same_alias_1, aliases: "nested"
|
38
39
|
attribute :same_alias_2, aliases: "nested"
|
@@ -102,6 +103,14 @@ describe "Cistern::Model" do
|
|
102
103
|
TypeSpec.new({"squash" => {"id" => "12", "type" => "fred"}}).vegetable.should == {"id" => "12", "type" => "fred"}
|
103
104
|
end
|
104
105
|
|
106
|
+
it "should set a default value" do
|
107
|
+
TypeSpec.new.default.should == "im a squash"
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should override a default value" do
|
111
|
+
TypeSpec.new(default: "now im a different squash").default.should == "now im a different squash"
|
112
|
+
end
|
113
|
+
|
105
114
|
context "allowing the same alias for multiple attributes" do
|
106
115
|
it "should do so when not squashing" do
|
107
116
|
type_spec = TypeSpec.new({"nested" => "bamboo"})
|
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: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: API client framework extracted from Fog
|
14
14
|
email:
|