Sha256: 9ae470f7a50a516230fce6ab30b52e333f9be68f4ad454212e44f81ce06756c4
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true module Magicka module Helper # @api private # # Options when generating {Helper} aggregator methods # # This is used when calling {Helper.with Helper.with} class AggregatorOptions < Sinclair::Options with_options :aggregator, :type, :config_block # @method config_block # @api private # # Block to be used when configuring a new aggregator class # # @return [Proc] # Returns the ready to use aggregator class # # @return [Class<Aggregator>] def configured_aggregator @configured_aggregator ||= configure_aggregator end # Type of the aggregator # # Type of aggregator will be used when defining the helper method # # @return [Symbol] def type @type ||= aggregator.type end private # @private # Configure the aggregator class by running {#config_block} # # @return [Class<Aggregator>] def configure_aggregator klass = aggregator_class return klass unless config_block klass.instance_eval(&config_block) klass end # @private # Return the aggregator class # # When aggregator class is defined as a String, this is then used to # return the correct class # # @return [Class<Aggregator>] def aggregator_class return aggregator if aggregator.is_a?(Class) aggregator.constantize end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
magicka-1.1.0 | lib/magicka/helper/aggregator_options.rb |