Module: Magicka::Helper::ClassMethods

Included in:
Magicka::Helper
Defined in:
lib/magicka/helper/class_methods.rb

Overview

Class methods for Magicka::Helper

Instance Method Summary collapse

Instance Method Details

#with(aggregator, type = nil, &block) ⇒ Array<NilClass>

Adds a helper method magicka_type

The created method executes a block with a an aggragator

Parameters:

  • aggregator_class (Class<Magicka::Aggregator>)

    Agragator to be initialized

  • type (String, Symbol) (defaults to: nil)

    type of aggregator, this will define the method name

  • config_block (Proc)

    block to be evaluated and configure the aggregator when it is first used

Returns:

  • (Array<NilClass>)


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/magicka/helper/class_methods.rb', line 8

def with(aggregator, type = nil, &block)
  options = AggregatorOptions.new(
    aggregator: aggregator,
    type: type,
    config_block: block
  )

  MethodBuilder.build(self, options) do
    build_aggregator
  end
end