Cerealize

Constants

VERSION

Public Class Methods

included(base) click to toggle source

Dirty functionality: note that *_changed? and changed? work, but *_was, *_change, and changes do NOT work.

    # File lib/cerealize.rb, line 19
19:   def self.included(base)
20:     base.send( :extend,    ClassMethods)
21:     base.send(:include, InstanceMethods)
22:   end

Public Instance Methods

codec_detect(str) click to toggle source
    # File lib/cerealize.rb, line 35
35:   def codec_detect(str)
36:     codecs.find{ |codec| codec.yours?(str) }
37:   end
codec_get(codec_name) click to toggle source
    # File lib/cerealize.rb, line 39
39:   def codec_get(codec_name)
40:     Codec.const_get(codec_name.to_s.capitalize)
41:   rescue NameError
42:     raise NoSuchCodec.new(codec_name)
43:   end
codec_names() click to toggle source
    # File lib/cerealize.rb, line 31
31:   def codec_names
32:     @codec_names ||= [:yaml, :marshal]
33:   end
codecs() click to toggle source
    # File lib/cerealize.rb, line 25
25:   def codecs
26:     @codecs ||= codec_names.map{ |codec_name|
27:                   codec_get(codec_name)
28:                 }
29:   end
decode(str, codec=nil) click to toggle source
    # File lib/cerealize.rb, line 50
50:   def decode(str, codec=nil)
51:     return nil unless str
52:     codec ||= codec_detect(str)
53: 
54:     if codec && codec.yours?(str)
55:       codec.decode(str)
56:     else
57:       raise NoSuitableCodec.new("#{str[0..46]}...")
58:     end
59:   end
encode(obj, codec) click to toggle source
    # File lib/cerealize.rb, line 45
45:   def encode(obj, codec)
46:     return nil unless obj
47:     codec.encode(obj)
48:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.