Sha256: 3a573ed58e5314157e48ebb1199fe2356dd5d378190f13081f7e277155b502bc

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require 'redis'

module Recommendable
  class Configuration
    # The ORM you are using. Currently supported: `:activerecord`, `:mongoid`, ':sequel', ':mongo-mapper' and `:datamapper`
    attr_accessor :orm

    # Recommendable's connection to Redis
    attr_accessor :redis

    # A prefix for all keys Recommendable uses
    attr_accessor :redis_namespace

    # Whether or not to automatically enqueue users to have their recommendations
    # refreshed after they like/dislike an item
    attr_accessor :auto_enqueue

    # The name of the queue that background jobs will be placed in
    attr_accessor :queue_name

    # The number of nearest neighbors (k-NN) to check when updating
    # recommendations for a user. Set to `nil` if you want to check all
    # neighbors as opposed to a subset of the nearest ones.
    attr_accessor :nearest_neighbors

    attr_accessor :ratable_classes, :user_class

    # Default values
    def initialize
      @redis             = Redis.new
      @redis_namespace   = :recommendable
      @auto_enqueue      = true
      @queue_name        = :recommendable
      @ratable_classes   = []
      @nearest_neighbors = nil
    end
  end

  class << self
    attr_accessor :config

    def configure
      @config ||= Configuration.new
      yield @config
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
recommendable-2.0.4.20130313 lib/recommendable/configuration.rb
recommendable-2.0.4 lib/recommendable/configuration.rb