class Esearch::Presenter::Facet

Base class for facets in results

Constants

REGISTRY
TYPE_KEY

Public Class Methods

build(raw) click to toggle source

Build facet from raw

@param [Hash] raw

@return [Facet]

@api private

# File lib/esearch/presenter/facet.rb, line 19
def self.build(raw)
  type = raw.fetch(TYPE_KEY)
  get(type).new(raw)
end

Private Class Methods

get(type) click to toggle source

Get class for type

@param [String] type

@return [Class:Facet]

@api private

# File lib/esearch/presenter/facet.rb, line 32
def self.get(type)
  REGISTRY.fetch(type) do
    fail "Facet with type #{type.inspect} is not known"
  end
end

Public Instance Methods

aspects() click to toggle source

Enumerate aspects

@return [Enumerable<Aspect>]

@api private

# File lib/esearch/presenter/facet.rb, line 45
def aspects
  util = self.class
  raw.fetch(util::FACET_KEY).map(&util::ASPECT_CLASS.method(:new))
end