Sha256: fbdc1abda45730f68f808e476efe8d9abdb7f01d69b76e82b402ce1272a2563a

Contents?: true

Size: 667 Bytes

Versions: 4

Compression:

Stored size: 667 Bytes

Contents

module Findable
  class Query
    module Namespace
      PREFIX = "findable".freeze
      KEY_NAMES = %i(info data lock index).freeze
      AUTO_INCREMENT_KEY = :auto_increment

      KEY_NAMES.each do |name|
        define_method([name, "key"].join("_")) { namespaces[name] }
      end

      def thread_key
        [PREFIX, basename].join("_")
      end

      private
        def basename
          model.model_name.plural
        end

        # @return [Hash] namespaces
        def namespaces
          @_namespaces ||= KEY_NAMES.each_with_object({}) {|key, obj|
            obj[key] = [PREFIX, basename, key].join(":")
          }
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
findable-0.2.2 lib/findable/query/namespace.rb
findable-0.2.1 lib/findable/query/namespace.rb
findable-0.2.0 lib/findable/query/namespace.rb
findable-0.1.5 lib/findable/query/namespace.rb