Class: Locabulary::Services::AllItemsForService Private
- Inherits:
-
Object
- Object
- Locabulary::Services::AllItemsForService
- 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
Class Method Summary collapse
- .call(options = {}) ⇒ Object private
- .reset_cache! ⇒ Object private
Instance Method Summary collapse
- #call ⇒ Object private
-
#initialize(options = {}) ⇒ AllItemsForService
constructor
private
A new instance of AllItemsForService.
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( = {}) @predicate_name = .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.
30 31 32 33 |
# File 'lib/locabulary/services/all_items_for_service.rb', line 30 def self.call( = {}) predicate_name = .fetch(:predicate_name) cache[predicate_name] ||= new().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.
21 22 23 |
# File 'lib/locabulary/services/all_items_for_service.rb', line 21 def self.reset_cache! @cache = {} end |
Instance Method Details
#call ⇒ 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.
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 |