Sha256: 9cce706e2fe430138de957328b1af2c8246a978146ce1e346efadeab8f3f65f4

Contents?: true

Size: 730 Bytes

Versions: 4

Compression:

Stored size: 730 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

4 entries across 4 versions & 1 rubygems

Version Path
findable-0.1.3 lib/findable/query/namespace.rb
findable-0.1.2 lib/findable/query/namespace.rb
findable-0.1.1 lib/findable/query/namespace.rb
findable-0.1.0 lib/findable/query/namespace.rb