Sha256: fac421fed392d0ff737f7fad2a9f6ca39ea7e0b78be03044cac23e09d083fe5e

Contents?: true

Size: 784 Bytes

Versions: 16

Compression:

Stored size: 784 Bytes

Contents

if defined?(Redis) && defined?(Redis::Namespace)

  begin
    tmp_rds = Redis::Namespace.new("#{Rails.application.class.parent_name}::active_page", redis: Redis.new(url: ENV.fetch('REDIS_URL') { 'redis://localhost:6379/1' }))

    tmp_rds.get('test')
  rescue
    if (!Rails.env.production? && !Boolean.parse(ENV.fetch('FORCE_REDIS') { false })) || Boolean.parse(ENV.fetch('ALLOW_FAKE_REDIS') { false })
      require BetterRecord::Engine.root.join('lib', 'better_record', 'fake_redis')
      puts "WARNING!!! Redis Server not found"
      tmp_rds = BetterRecord::FakeRedis.new
    else
      raise
    end
  end

  Rails.application.class.parent.const_set('REDIS', tmp_rds)

  module Rails
    def self.redis
      Rails.application.class.parent.const_get('REDIS')
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
better_record-0.8.0 config/initializers/redis_store.rb
better_record-0.7.5 config/initializers/redis_store.rb
better_record-0.7.4 config/initializers/redis_store.rb
better_record-0.7.3 config/initializers/redis_store.rb
better_record-0.7.2 config/initializers/redis_store.rb
better_record-0.7.1 config/initializers/redis_store.rb
better_record-0.7.0 config/initializers/redis_store.rb
better_record-0.6.1 config/initializers/redis_store.rb
better_record-0.6.0 config/initializers/redis_store.rb
better_record-0.5.5 config/initializers/redis_store.rb
better_record-0.5.4 config/initializers/redis_store.rb
better_record-0.5.1 config/initializers/redis_store.rb
better_record-0.5.0 config/initializers/redis_store.rb
better_record-0.4.0 config/initializers/redis_store.rb
better_record-0.3.0 config/initializers/redis_store.rb
better_record-0.2.0 config/initializers/redis_store.rb