Sha256: 2ef11dc10360af24357fb37f020e42dc19644065f402bd74b3f469b321545d10
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'date' require 'locabulary/item' require 'locabulary/utility' module Locabulary # :nodoc: module Services # @api private # # Responsible for extracting a non-hierarchical sorted array of Locabulary::Item for the given predicate_name # # @see Locabulary::Item class AllItemsForService def self.cache @cache ||= {} end private_class_method :cache # @api private # @since 0.7.0 def self.reset_cache! @cache = {} end # @api private # @since 0.7.0 # # @param options [Hash] # @option options [String] :predicate_name def self.call(options = {}) predicate_name = options.fetch(:predicate_name) cache[predicate_name] ||= new(options).call end private_class_method :new def initialize(options = {}) @predicate_name = options.fetch(:predicate_name) @builder = Item.builder_for(predicate_name: predicate_name) end def call collector = [] Utility.with_extraction_for(predicate_name) do |data| collector << builder.call(data.merge('predicate_name' => predicate_name)) end collector.sort end private attr_reader :predicate_name, :as_of, :builder end private_constant :ActiveItemsForService end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locabulary-0.8.1 | lib/locabulary/services/all_items_for_service.rb |
locabulary-0.7.1 | lib/locabulary/services/all_items_for_service.rb |