Class: Locabulary::Services::AllItemsForService Private

Inherits:
Object
  • Object
show all
Defined in:
lib/locabulary/services/all_items_for_service.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Responsible for extracting a non-hierarchical sorted array of Locabulary::Item for the given predicate_name

See Also:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AllItemsForService

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AllItemsForService.



37
38
39
40
# File 'lib/locabulary/services/all_items_for_service.rb', line 37

def initialize(options = {})
  @predicate_name = options.fetch(:predicate_name)
  @builder = Item.builder_for(predicate_name: predicate_name)
end

Class Method Details

.call(options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

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

Options Hash (options):

  • :predicate_name (String)

Since:

  • 0.7.0



30
31
32
33
# File 'lib/locabulary/services/all_items_for_service.rb', line 30

def self.call(options = {})
  predicate_name = options.fetch(:predicate_name)
  cache[predicate_name] ||= new(options).call
end

.reset_cache!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.7.0



21
22
23
# File 'lib/locabulary/services/all_items_for_service.rb', line 21

def self.reset_cache!
  @cache = {}
end

Instance Method Details

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
# File 'lib/locabulary/services/all_items_for_service.rb', line 42

def call
  collector = []
  Utility.with_extraction_for(predicate_name) do |data|
    collector << builder.call(data.merge('predicate_name' => predicate_name))
  end
  collector.sort
end