Sha256: ece46d4fc0dc5f9f8320519f051edd6a763b4179fed549a4622be68f9d6b05ff

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

require_relative "../request"

class Skala::Adapter::Search::Request::Facet
  include Virtus.model

  attribute :type, String, default: -> (instance, _) do
    class_name = instance.class.to_s.demodulize.underscore

    if (splitted_class_name = class_name.split("_")).last == "facet"
      splitted_class_name[0..-2].join("_")
    else
      class_name
    end
  end

  require_relative "./histogram_facet"
  require_relative "./range_facet"
  require_relative "./terms_facet"

  def self.factory(options)
    if (options[:type] || options["type"]) == "histogram"
      parent::HistogramFacet.new(options)
    elsif (options[:type] || options["type"]) == "range"
      parent::RangeFacet.new(options)
    elsif (options[:type] || options["type"]) == "terms"
      parent::TermsFacet.new(options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skala-1.1.0 lib/skala/adapter/search/request/facet.rb