# File lib/deltacloud/method_serializer.rb, line 60 def self.wrap_methods(c, opts={}) $methods_cache_dir = opts[:cache_dir] $scenario_prefix = nil c.class_eval do cached_methods.each do |m| next if c.instance_methods(false).include?("original_#{m}") alias_method "original_#{m}".to_sym, m.to_sym define_method m.to_sym do |*args| args = args.first if args.size.eql?(1) and not args.first.class.eql?(Array) output = deserialize_data(m, args) unless output output = method("original_#{m}".to_sym).to_proc[args] return serialize_data(m, args, output) else return output end end end end end
# File lib/deltacloud/method_serializer.rb, line 47 def args_hash(args) if args.class == Hash args = args.to_a.collect {|i| [i[0].to_s, i[1]]}.sort end Digest::SHA1.hexdigest(args.to_s) end
# File lib/deltacloud/method_serializer.rb, line 24 def cache_dir storage_dir = $methods_cache_dir || File.join(File.dirname(__FILE__), 'cache') class_dir = self.class.name.split('::').last class_dir ||= self.class.name File.join(storage_dir, class_dir.downcase) end
# File lib/deltacloud/method_serializer.rb, line 54 def cache_file_name(method_name, args) FileUtils.mkdir_p(cache_dir) unless File.directory?(cache_dir) method_name = $scenario_prefix ? "#{$scenario_prefix}_#{method_name}" : method_name File.join(cache_dir, "#{method_name}.#{args_hash(args)}") end
Generated with the Darkfish Rdoc Generator 2.