Class: Locabulary::FacetWrapperForItem

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/locabulary/facet_wrapper_for_item.rb

Overview

A wrapper for a Locabulary::Items::Base that includes information from the SOLR Utility.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FacetWrapperForItem

Returns a new instance of FacetWrapperForItem.



48
49
50
51
52
# File 'lib/locabulary/facet_wrapper_for_item.rb', line 48

def initialize(options = {})
  @__faceted_node__ = options.fetch(:faceted_node)
  @__locabulary_item__ = options.fetch(:locabulary_item)
  super(@__locabulary_item__)
end

Instance Attribute Details

#__faceted_node__Object (readonly)

Returns the value of attribute faceted_node.



54
55
56
# File 'lib/locabulary/facet_wrapper_for_item.rb', line 54

def __faceted_node__
  @__faceted_node__
end

#__locabulary_item__Object (readonly)

Returns the value of attribute locabulary_item.



54
55
56
# File 'lib/locabulary/facet_wrapper_for_item.rb', line 54

def __locabulary_item__
  @__locabulary_item__
end

Class Method Details

.build_for_faceted_node(options = {}) ⇒ Object

In some cases, we may have a facet with a term_label that is not found in the existing data storage. Instead of throwing an exception, we can make a reasonable approximation for that item based on the given parameters.

Parameters:

  • options (Hash) (defaults to: {})
  • predicate_name (Hash)

    a customizable set of options

  • faceted_node (Hash)

    a customizable set of options

  • term_label (Hash)

    a customizable set of options

Returns:

  • Locabulary::FacetWrapperForItem

See Also:

  • Locabulary::FacetedHierarchicalTreeSorter

Since:

  • 0.5.0



22
23
24
25
26
27
28
# File 'lib/locabulary/facet_wrapper_for_item.rb', line 22

def self.build_for_faceted_node(options = {})
  predicate_name = options.fetch(:predicate_name)
  faceted_node = options.fetch(:faceted_node)
  term_label = options.fetch(:term_label)
  locabulary_item = Item.build(predicate_name: predicate_name, term_label: term_label, default_presentation_sequence: nil)
  new(faceted_node: faceted_node, locabulary_item: locabulary_item)
end

.build_for_faceted_node_and_locabulary_item(options = {}) ⇒ Object

In some cases, we have a facet and a locabulary item and this is the public method for building the wrapped object.

Parameters:

  • options (Hash) (defaults to: {})
  • predicate_name (Hash)

    a customizable set of options

  • faceted_node (Hash)

    a customizable set of options

  • term_label (Hash)

    a customizable set of options

Returns:

  • Locabulary::FacetWrapperForItem

See Also:

  • Locabulary::FacetedHierarchicalTreeSorter

Since:

  • 0.5.0



41
42
43
# File 'lib/locabulary/facet_wrapper_for_item.rb', line 41

def self.build_for_faceted_node_and_locabulary_item(options = {})
  new(options)
end