Sha256: b71dc4e06db1878e365ec3c6a43dd9f12dae2963230b8f64b2f544c476fbdf64

Contents?: true

Size: 1009 Bytes

Versions: 2

Compression:

Stored size: 1009 Bytes

Contents

require "user_settings/version"
require "user_settings/route_drawers/default"

require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext'

module UserSettings

  # Redis options are
  # * host
  # * port
  # * db
  # * redis_connection - Give a connection directly
  #
  mattr_accessor :redis_options
  @@redis_options = false
  @@redis_connection = nil

  mattr_accessor :base_path
  @@base_path = 'usettings/'

  mattr_accessor :route_drawer
  @@route_drawer = UserSettings::RouteDrawers::Default

  mattr_accessor :expiration_time
  @@expiration_time = 3.months

  def self.configure
    yield self
  end

  def self.redis
    if @@redis_options
      @@redis_connection ||= @@redis_options.delete(:redis_connection)
      if @@redis_connection == nil
        @@redis_connection ||= Redis.new({:host => 'localhost', :port => 6379, :db => 1}.merge(@@redis_options))
      end
    end
    @@redis_connection
  end

  require 'user_settings/engine' if defined?(Rails)

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
user_settings-0.0.2 lib/user_settings.rb
user_settings-0.0.1 lib/user_settings.rb