Sha256: a7be5288bbe4a401103f43664c184a4462de5c74c327644e0fd76d0e22009987

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

module Recommendable
  module Helpers
    module RedisKeyMapper
      class << self
        %w[liked disliked hidden bookmarked recommended].each do |action|
          define_method "#{action}_set_for" do |klass, id|
            [Recommendable.config.redis_namespace, Recommendable.config.user_class.to_s.tableize, id, "#{action}_#{klass.to_s.tableize}"].compact.join(':')
          end
        end

        def similarity_set_for(id)
          [Recommendable.config.redis_namespace, Recommendable.config.user_class.to_s.tableize, id, 'similarities'].compact.join(':')
        end

        def liked_by_set_for(klass, id)
          [Recommendable.config.redis_namespace, klass.to_s.tableize, id, 'liked_by'].compact.join(':')
        end

        def disliked_by_set_for(klass, id)
          [Recommendable.config.redis_namespace, klass.to_s.tableize, id, 'disliked_by'].compact.join(':')
        end

        def score_set_for(klass)
          [Recommendable.config.redis_namespace, klass.to_s.tableize, 'scores'].join(':')
        end

        def temp_set_for(klass, id)
          [Recommendable.config.redis_namespace, klass.to_s.tableize, id, 'temp'].compact.join(':')
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
recommendable-2.1.2 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.1.1 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.1.0.2 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.1.0.1 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.0.4.20130313 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.0.4 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.0.3 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.0.2 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.0.1 lib/recommendable/helpers/redis_key_mapper.rb
recommendable-2.0.0.20121011 lib/recommendable/helpers/redis_key_mapper.rb