Browse files

* FIXED: Added calls to preprocess in the to_FORMAT methods.

* FIXED: Added calls to postprocess in from_delimited
* CHANGE: Remove initialize completely
  • Loading branch information...
1 parent 4a2a399 commit d41d9a898df812c5a5711de1e902f5e739ec38a2 @delano committed Dec 25, 2010
Showing with 13 additions and 6 deletions.
  1. +7 −0 CHANGES.txt
  2. +6 −6 lib/storable.rb
View
7 CHANGES.txt
@@ -3,6 +3,13 @@ STORABLE, CHANGES
* TODO: Handle nested hashes and arrays.
* TODO: to_xml, see: http://codeforpeople.com/lib/ruby/xx/xx-2.0.0/README
+#### 0.8.5 (2010-12-25) #############################
+
+* FIXED: Added calls to preprocess in the to_FORMAT methods.
+* FIXED: Added calls to postprocess in from_delimited
+* CHANGE: Remove initialize completely
+
+
#### 0.8.4 (2010-12-23) #############################
* CHANGE: Moved initialize logic to Storable.from_array.
View
12 lib/storable.rb
@@ -125,12 +125,6 @@ def has_field?(n)
# See SUPPORTED_FORMATS for available values.
attr_reader :format
- # +args+ is a list of values to set amongst the fields.
- # It's assumed that the order values matches the order
- def initialize(*args)
- preprocess if respond_to? :preprocess
- end
-
# See SUPPORTED_FORMATS for available values
def format=(v)
v &&= v.to_sym
@@ -211,6 +205,7 @@ def self.from_array(*from)
break if index >= from.size
me.send("#{n}=", from[index])
end
+ me.postprocess
me
end
@@ -289,6 +284,7 @@ def from_hash(from={})
# Return the object data as a hash
# +with_titles+ is ignored.
def to_hash
+ preprocess if respond_to? :preprocess
tmp = USE_ORDERED_HASH ? Storable::OrderedHash.new : {}
field_names.each do |fname|
next if sensitive? && self.class.sensitive_field?(fname)
@@ -303,6 +299,7 @@ def to_hash
end
def to_array
+ preprocess if respond_to? :preprocess
fields = sensitive? ? (field_names-sensitive_fields) : field_names
fields.collect do |fname|
next if sensitive? && self.class.sensitive_field?(fname)
@@ -316,6 +313,7 @@ def to_array
end
def to_json(*from, &blk)
+ preprocess if respond_to? :preprocess
hash = to_hash
if YAJL_LOADED # set by Storable
ret = Yajl::Encoder.encode(hash)
@@ -331,6 +329,7 @@ def to_json(*from, &blk)
end
def to_yaml(*from, &blk)
+ preprocess if respond_to? :preprocess
to_hash.to_yaml(*from, &blk)
end
@@ -376,6 +375,7 @@ def self.from_json(*from)
# +with_titles+ specifiy whether to include field names (default: false)
# +delim+ is the field delimiter.
def to_delimited(with_titles=false, delim=',')
+ preprocess if respond_to? :preprocess
values = []
fields = sensitive? ? (field_names-sensitive_fields) : field_names
fields.each do |fname|

0 comments on commit d41d9a8

Please sign in to comment.