Sha256: cd4c6895ee26557df41a3c333f0e65b810232768f01e59f79513dd10b8877bd5

Contents?: true

Size: 1.16 KB

Versions: 108

Compression:

Stored size: 1.16 KB

Contents

module Scrivito
module Backend

# Abstract Base for Index Implementations
module Index

  IMPLEMENTATIONS = [
    Backend::PathIndex,
    Backend::ParentPathIndex,
    Backend::PermalinkIndex,
  ].freeze

  IMPLEMENTATION_BY_NAME = IMPLEMENTATIONS.inject({}) do |result, index|
    result.merge(index.id => index)
  end

  def self.by_name(name)
    IMPLEMENTATION_BY_NAME[name.to_s] or
      raise Scrivito::InternalError, "unknown index #{name}"
  end

  def id
    abstract_base_method
  end

  def update(key, cached_result, change_index)
    updated = Set.new(cached_result)

    change_index.each do |id, data|
      value = extract_update_value_from_data(data)

      if value == key
        updated.add(id)
      else
        updated.delete(id)
      end
    end

    updated.to_a
  end

  def extract_update_value_from_data(data)
    abstract_base_method
  end

  def group_by(keys, obj_datas)
    return [obj_datas] if keys.length == 1

    group_by_multiple(keys, obj_datas)
  end

  def group_by_multiple(parent_paths, obj_datas)
    abstract_base_method
  end

  private

  def abstract_base_method
    raise Scrivito::InternalError, "not implemented"
  end

end

end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
scrivito_sdk-1.17.0 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.17.0.rc3 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.17.0.rc2 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.17.0.rc1 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.16.0 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.16.0.rc2 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.16.0.rc1 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.15.0 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.15.0.rc2 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.15.0.rc1 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.14.0 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.14.0.rc3 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.14.0.rc2 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.14.0.rc1 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.13.0 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.13.0.rc2 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.13.0.rc1 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.12.0 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.12.0.rc2 app/cms/scrivito/backend/index.rb
scrivito_sdk-1.12.0.rc1 app/cms/scrivito/backend/index.rb