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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d585ea5371e0aacb6be60961d9f84092f33e44b
4
- data.tar.gz: 03cea31b26b0a9ffab12c9d5e676297fb671ed35
3
+ metadata.gz: c3de1bf9f141d828eb4bf959659312d6f42f9f4d
4
+ data.tar.gz: e925e41ac94223d588567509c2ac7851c21f074b
5
5
  SHA512:
6
- metadata.gz: e968344a6b10ace08f87ba1222b5fdd8b8bacc5593733624ea53f818d9faef2d81822171d20ac12aa0163fd7778856b402078a3527bb3d5049be306b8f063a02
7
- data.tar.gz: 99301cc7e296366fc8cab118e1c876e09f092218a8328df6936e37bcc50ccf08d39bca08f6eff9f70ce30556130584aa929566d47e03aec94128ed9dcbf5e54d
6
+ metadata.gz: bfe27266c4b6b4b4ab467b667eed563fbc1eca9b7466f9b8a6e60c0074c60e62222acd745d566a9e833fcb8d4aa71e3a980ef6e0f0081ddb1403f3d615b25d5a
7
+ data.tar.gz: b413e43327c69559351136add3012cd708a50b7cc69da31d18e4d4900643b5e70b17abc619b30ad2fb0e38df071b9601235b5f9084e71c7b159c4fb5ab209c70
@@ -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
- # record the attribute was accessed
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
- transformed = transform.call(name, value, options)
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
@@ -1,3 +1,3 @@
1
1
  module Cistern
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  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: 0.8.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-13 00:00:00.000000000 Z
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: