Class: Magicka::Helper::MethodBuilder

Inherits:
Sinclair
  • Object
show all
Defined in:
lib/magicka/helper/method_builder.rb

Overview

Builds methods for Magicka::Helper

Instance Method Summary collapse

Instance Method Details

#build_aggregator(aggregator_class, type = aggregator_class.type) ⇒ 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: aggregator_class.type)

    type of aggregator, this will define the method name

Returns:

  • (Array<NilClass>)


8
9
10
11
12
13
14
# File 'lib/magicka/helper/method_builder.rb', line 8

def build_aggregator(aggregator_class, type = aggregator_class.type)
  add_method("magicka_#{type}") do |model, &block|
    block.call(aggregator_class.new(self, model))
  end

  build
end