Sha256: f142a79668b724ad2a7fda329c0c1e9482f66bcf47168cfd06109b3e8e201411

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

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

      def initialize(model)
        @_model = model
      end

      KEY_NAMES.each do |key|
        define_method([key, "key"].join("_")) { namespaces[key] }
      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

1 entries across 1 versions & 1 rubygems

Version Path
findable-0.1.4 lib/findable/query/namespace.rb