Sha256: c9aa63f7f7b04d81110a254f070cfc64e09ef1421e6b27f251b05f05481d5c98

Contents?: true

Size: 1.43 KB

Versions: 22

Compression:

Stored size: 1.43 KB

Contents

require 'multi_json'

# OkJson won't work because it doesn't serialize symbols
# in the same way yajl and json do.
if MultiJson.respond_to?(:adapter)
  raise "Please install the yajl-ruby or json gem" if MultiJson.adapter.to_s == 'MultiJson::Adapters::OkJson'
elsif MultiJson.respond_to?(:engine)
  raise "Please install the yajl-ruby or json gem" if MultiJson.engine.to_s == 'MultiJson::Engines::OkJson'
end

module Resque
  # Methods used by various classes in Resque.
  module Helpers
    class DecodeException < StandardError; end

    # Direct access to the Redis instance.
    def redis
      # No infinite recursions, please.
      # Some external libraries depend on Resque::Helpers being mixed into
      # Resque, but this method causes recursions. If we have a super method,
      # assume it is canonical. (see #1150)
      return super if defined?(super)

      Resque.redis
    end

    # Given a Ruby object, returns a string suitable for storage in a
    # queue.
    def encode(object)
      Resque.encode(object)
    end

    # Given a string, returns a Ruby object.
    def decode(object)
      Resque.decode(object)
    end

    # Given a word with dashes, returns a camel cased version of it.
    def classify(dashed_word)
      Resque.classify(dashed_word)
    end

    # Tries to find a constant with the name specified in the argument string
    def constantize(camel_cased_word)
      Resque.constantize(camel_cased_word)
    end
  end
end

Version data entries

22 entries across 22 versions & 6 rubygems

Version Path
resque-2.7.0 lib/resque/helpers.rb
resque-2.6.0 lib/resque/helpers.rb
resque-2.5.0 lib/resque/helpers.rb
resque-2.4.0 lib/resque/helpers.rb
resque-2.3.0 lib/resque/helpers.rb
resque-2.2.1 lib/resque/helpers.rb
resque-2.2.0 lib/resque/helpers.rb
resque-2.1.0 lib/resque/helpers.rb
resque-2.0.0 lib/resque/helpers.rb
resque_admin-1.0.4 lib/resque_admin/helpers.rb
resque_admin-1.0.3 lib/resque/helpers.rb
resque_admin-1.0.2 lib/resque/helpers.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/resque-1.27.4/lib/resque/helpers.rb
resque-1.27.4 lib/resque/helpers.rb
resque-1.27.3 lib/resque/helpers.rb
resque-1.27.2 lib/resque/helpers.rb
resque-1.27.1 lib/resque/helpers.rb
resque-1.27.0 lib/resque/helpers.rb
resqueue-1.0.0 lib/resque/helpers.rb
resque-master-0.0.3 lib/resque/helpers.rb