module Storable::DefaultProcessors

These methods can be used by Storable objects as custom field processors.

e.g.

class A < Storable
  field :name => String, &hash_proc_processor
end

Public Instance Methods

gibbler_id_processor() click to toggle source

If the object already has a value for +@id+ use it, otherwise return the current digest.

This allows an object to have a preset ID.

# File lib/storable.rb, line 543
def gibbler_id_processor
  Proc.new do |val|
    @id || self.gibbler
  end
end
hash_proc_processor() click to toggle source

Replace a hash of Proc objects with a hash of

# File lib/storable.rb, line 521
def hash_proc_processor 
  Proc.new do |procs|
    a = {}
    unless procs.nil?
      procs.each_pair { |n,v| 
        a[n] = (Proc === v) ? v.source : v 
      }
    end
    a
  end
end
proc_processor() click to toggle source
# File lib/storable.rb, line 532
def proc_processor
  Proc.new do |val|
    ret = (Proc === val) ? val.source : val 
    ret
  end
end