cistern 0.8.0 → 0.9.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 +21 -12
- data/lib/cistern/version.rb +1 -1
- 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: c3de1bf9f141d828eb4bf959659312d6f42f9f4d
|
4
|
+
data.tar.gz: e925e41ac94223d588567509c2ac7851c21f074b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfe27266c4b6b4b4ab467b667eed563fbc1eca9b7466f9b8a6e60c0074c60e62222acd745d566a9e833fcb8d4aa71e3a980ef6e0f0081ddb1403f3d615b25d5a
|
7
|
+
data.tar.gz: b413e43327c69559351136add3012cd708a50b7cc69da31d18e4d4900643b5e70b17abc619b30ad2fb0e38df071b9601235b5f9084e71c7b159c4fb5ab209c70
|
data/lib/cistern/attributes.rb
CHANGED
@@ -70,17 +70,8 @@ module Cistern::Attributes
|
|
70
70
|
|
71
71
|
name = _name.to_s.to_sym
|
72
72
|
|
73
|
-
parser = Cistern::Attributes.parsers[options[:type]] ||
|
74
|
-
options[:parser] ||
|
75
|
-
Cistern::Attributes.default_parser
|
76
|
-
transform = Cistern::Attributes.transforms[options[:squash] ? :squash : :none] ||
|
77
|
-
Cistern::Attributes.default_transform
|
78
|
-
|
79
73
|
self.send(:define_method, name) do
|
80
|
-
|
81
|
-
self.class.attributes[name.to_s.to_sym][:coverage_hits] += 1 rescue nil
|
82
|
-
|
83
|
-
attributes.fetch(name.to_s.to_sym, options[:default])
|
74
|
+
read_attribute(name)
|
84
75
|
end unless self.instance_methods.include?(name)
|
85
76
|
|
86
77
|
if options[:type] == :boolean
|
@@ -88,8 +79,7 @@ module Cistern::Attributes
|
|
88
79
|
end
|
89
80
|
|
90
81
|
self.send(:define_method, "#{name}=") do |value|
|
91
|
-
|
92
|
-
attributes[name.to_s.to_sym]= parser.call(transformed, options)
|
82
|
+
write_attribute(name, value)
|
93
83
|
end unless self.instance_methods.include?("#{name}=".to_sym)
|
94
84
|
|
95
85
|
if self.attributes[name]
|
@@ -123,6 +113,25 @@ module Cistern::Attributes
|
|
123
113
|
Marshal.dump(attributes)
|
124
114
|
end
|
125
115
|
|
116
|
+
def read_attribute(name)
|
117
|
+
options = self.class.attributes[name] || {}
|
118
|
+
# record the attribute was accessed
|
119
|
+
self.class.attributes[name.to_s.to_sym][:coverage_hits] += 1 rescue nil
|
120
|
+
|
121
|
+
attributes.fetch(name.to_s.to_sym, options[:default])
|
122
|
+
end
|
123
|
+
|
124
|
+
def write_attribute(name, value)
|
125
|
+
options = self.class.attributes[name] || {}
|
126
|
+
transform = Cistern::Attributes.transforms[options[:squash] ? :squash : :none] ||
|
127
|
+
Cistern::Attributes.default_transform
|
128
|
+
parser = Cistern::Attributes.parsers[options[:type]] ||
|
129
|
+
options[:parser] ||
|
130
|
+
Cistern::Attributes.default_parser
|
131
|
+
transformed = transform.call(name, value, options)
|
132
|
+
attributes[name.to_s.to_sym]= parser.call(transformed, options)
|
133
|
+
end
|
134
|
+
|
126
135
|
def attributes
|
127
136
|
@attributes ||= {}
|
128
137
|
end
|
data/lib/cistern/version.rb
CHANGED
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.9.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-06-
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: API client framework extracted from Fog
|
14
14
|
email:
|