public
Rubygem
Description: JSON Web App Framework
Homepage: http://halcyon.rubyforge.org/
Clone URL: git://github.com/mtodd/halcyon.git
Click here to lend your support to: halcyon and make a donation at www.pledgie.com !
Added testing for configurations that araren't hashes to prevent loss of 
data.
mtodd (author)
Tue Jul 01 13:51:33 -0700 2008
commit  cab63de1e74a787c077fa33bd53ca912afe82309
tree    6e49f06f5d0306fe8592a50b994f0c19ae0fe7cd
parent  aebf7c7dcf365f771a2f007faf0eaf3abbc6ffc0
...
43
44
45
 
 
46
47
 
48
49
50
51
52
53
 
 
 
 
 
54
55
56
57
58
59
 
60
61
62
...
43
44
45
46
47
48
 
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
66
67
68
69
0
@@ -43,20 +43,27 @@ module Halcyon
0
       # # parsing errors will happen if you try to use the wrong marshal
0
       # # load method
0
       #
0
+ # Returns a Mash if the contents parse to a Hash.
0
+ #
0
       def to_hash(from = :from_yaml)
0
- Mash.new case from
0
+ contents = case from
0
         when :from_yaml
0
           require 'yaml'
0
           YAML.load(self.content)
0
         when :from_json
0
           JSON.parse(self.content)
0
         end
0
+ # return mash instead of hash if result is a hash
0
+ if contents.is_a?(Hash)
0
+ contents = Mash.new contents
0
+ end
0
+ contents
0
       end
0
       
0
       # Filters the contents through ERB.
0
       #
0
       def filter(content, filter_through_erb)
0
- content = ERB.new(content).result if filter_through_erb
0
+ content = ERB.new(content).result if filter_through_erb
0
         content
0
       end
0
       

Comments

    No one has commented yet.