cistern 0.5.10 → 0.6.0

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: 06c6ce008de39695dfbae8ca9e6c5429e75c675f
4
- data.tar.gz: b049614c035bf9a4284d5e7c6b1f20085a544b8d
3
+ metadata.gz: 7013053b6babdbcbc398b16bb018cc889cfd01c7
4
+ data.tar.gz: 81c10f424574419b9bf216ea4a3fec9ec9327b23
5
5
  SHA512:
6
- metadata.gz: e04b4dbbe14e346c0388c3fd00c341f48638d7384e32a6328088dc0744000f71b6d36a684494ff37fd3028ccc7d73a655743e3adfae45e06c375dfbd2b9c0b13
7
- data.tar.gz: 14fe25476a2f3ebac056bec9636a30b07d41d4ed97d9d45e62988ba8279c2a7f0ea4e0018a9d183ac44ff95d6eecc60cc4e074113f60231e1c61d1f3323c8854
6
+ metadata.gz: 9238df8c51907706409456fb98a7b1181610b7c761efee3f8d0bc427fb498d1fec4e21a1cbbab71e9619dad62aa33df0bd448b449c9706a5a5aa8bc8c1e55780
7
+ data.tar.gz: a162d7a75411925f030e30070fb8ec28c1de78eaa10a897f37ebc8cdd9dee818e47b4d1233701f9061417da3b7d6292f5c39c9c5a859c9b9680ac3d3a2e6efa4
@@ -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[name.to_s.to_sym]
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
@@ -1,3 +1,3 @@
1
1
  module Cistern
2
- VERSION = "0.5.10"
2
+ VERSION = "0.6.0"
3
3
  end
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.5.10
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-16 00:00:00.000000000 Z
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: