Class: Magicka::Aggregator::MethodBuilder Private

Inherits:
Sinclair
  • Object
show all
Defined in:
lib/magicka/aggregator/method_builder.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.

Class responsible for building an Magicka::Aggregator method

Instance Method Summary collapse

Constructor Details

#initialize(klass, element_class, method_name = nil) ⇒ MethodBuilder

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 MethodBuilder.



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

def initialize(klass, element_class, method_name = nil)
  super(klass)

  @element_class = element_class
  @method_name = method_name
end

Instance Method Details

#prepareObject

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.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/magicka/aggregator/method_builder.rb', line 16

def prepare
  element_klass = element_class

  add_method(method_name) do |field, model: self.model, **args|
    element_klass.render(
      renderer: renderer, field: field, model: model, **args
    )
  end

  self
end