Module: Recommendable

Defined in:
lib/recommendable.rb,
lib/recommendable/rater.rb,
lib/recommendable/ratable.rb,
lib/recommendable/version.rb,
lib/recommendable/rater/hider.rb,
lib/recommendable/rater/liker.rb,
lib/recommendable/configuration.rb,
lib/recommendable/rater/disliker.rb,
lib/recommendable/workers/resque.rb,
lib/recommendable/ratable/likable.rb,
lib/recommendable/workers/sidekiq.rb,
lib/recommendable/helpers/queriers.rb,
lib/recommendable/rater/bookmarker.rb,
lib/recommendable/rater/recommender.rb,
lib/recommendable/ratable/dislikable.rb,
lib/recommendable/workers/torque_box.rb,
lib/recommendable/workers/delayed_job.rb,
lib/recommendable/helpers/calculations.rb,
lib/recommendable/helpers/redis_key_mapper.rb

Defined Under Namespace

Modules: Helpers, Ratable, Rater, Workers Classes: Configuration, Version

Constant Summary collapse

VERSION =
Version.to_s.freeze

Class Method Summary collapse

Class Method Details

.configObject



75
76
77
# File 'lib/recommendable/configuration.rb', line 75

def config
  @config ||= Configuration.new
end

.configure {|@config| ... } ⇒ Object

Yields:



70
71
72
73
# File 'lib/recommendable/configuration.rb', line 70

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

.enqueue(user_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/recommendable.rb', line 25

def enqueue(user_id)
  user_id = user_id.id if user_id.is_a?(Recommendable.config.user_class)
  user_id = user_id.to_s

  if defined?(::Sidekiq)
    Recommendable::Workers::Sidekiq.perform_async(user_id)
  elsif defined?(::Resque)
    Resque.enqueue(Recommendable::Workers::Resque, user_id)
  elsif defined?(::Delayed::Job)
    Delayed::Job.enqueue(Recommendable::Workers::DelayedJob.new(user_id))
  elsif defined?(::TorqueBox::Messaging::Backgroundable)
    Recommendable::Workers::TorqueBox.enqueue(user_id)
  elsif defined?(::Rails::Queueing)
    unless Rails.queue.any? { |w| w.user_id == user_id }
      Rails.queue.push(Recommendable::Workers::Rails.new(user_id))
      Rails.application.queue_consumer.start
    end
  end
end

.query(klass, ids) ⇒ Object



19
20
21
22
23
# File 'lib/recommendable.rb', line 19

def query(klass, ids)
    Recommendable::Helpers::Queriers.send(Recommendable.config.orm, klass, ids)
  rescue NoMethodError
    warn 'Your ORM is not currently supported. Please open an issue at https://github.com/davidcelis/recommendable'
end

.redisObject



17
# File 'lib/recommendable.rb', line 17

def redis() config.redis end