module Kthxbye module Helper #:nodoc: all def redis Kthxbye.redis end def log(msg) if Kthxbye::Config.options[:verbose] puts "!! #{msg} - #{Time.now.strftime("%I:%M%p")}" end end # # encode/decode code taken and modified from Resque # (http://github.com/defunkt/resque/blob/master/lib/resque/helpers.rb) # def encode( data ) if defined? Yajl Yajl::Encoder.encode(data) else data.to_json end end def decode( data ) return unless data if defined? Yajl begin Yajl::Parser.parse( data, :check_utf8 => false ) rescue Yajl::ParseError end else begin JSON.parse( data ) rescue JSON::ParseError end end end end end