Sha256: 7efc266b39a874541aa423b09547539facdda43f5c83e756315f35c883c6c774

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module Picky

  module Backends

    class Memory < Backend

      # Returns an object that on #initial, #load returns
      # an object that responds to:
      #   [:token] # => [id, id, id, id, id] (an array of ids)
      #
      def create_inverted bundle
        extract_lambda_or(inverted, bundle) ||
          JSON.new(bundle.index_path(:inverted))
      end
      # Returns an object that on #initial, #load returns
      # an object that responds to:
      #   [:token] # => 1.23 (a weight)
      #
      def create_weights bundle
        extract_lambda_or(weights, bundle) ||
          JSON.new(bundle.index_path(:weights))
      end
      # Returns an object that on #initial, #load returns
      # an object that responds to:
      #   [:encoded] # => [:original, :original] (an array of original symbols this similarity encoded thing maps to)
      #
      def create_similarity bundle
        extract_lambda_or(similarity, bundle) ||
          Marshal.new(bundle.index_path(:similarity))
      end
      # Returns an object that on #initial, #load returns
      # an object that responds to:
      #   [:key] # => value (a value for this config key)
      #
      def create_configuration bundle
        extract_lambda_or(configuration, bundle) ||
          JSON.new(bundle.index_path(:configuration))
      end
      # Returns an object that on #initial, #load returns
      # an object that responds to:
      #   [id] # => [:sym1, :sym2]
      #
      def create_realtime bundle
        extract_lambda_or(similarity, bundle) ||
          JSON.new(bundle.index_path(:realtime))
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-4.0.0pre2 lib/picky/backends/memory.rb