Module: Magicka::Aggregator::ClassMethods

Included in:
Magicka::Aggregator
Defined in:
lib/magicka/aggregator/class_methods.rb

Overview

Class methods for Magicka::Aggregator

Instance Method Summary collapse

Instance Method Details

#type(new_type = nil) ⇒ Symbol

Set and return the type of the aggregator

When new_type is ommited, returns the last value

Parameters:

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

    The value to be set

Returns:

  • (Symbol)

    the type of the aggregator



22
23
24
25
26
# File 'lib/magicka/aggregator/class_methods.rb', line 22

def type(new_type = nil)
  return @type ||= default_type unless new_type

  @type = new_type.to_sym
end

#with_element(element_class, method_name = nil, template: nil) ⇒ Array<NilClass> #with_element(element_class_name, method_name = nil, template: nil) ⇒ Array<NilClass>

Configure an Magicka::Aggregator adding a method to render an element

Overloads:

  • #with_element(element_class, method_name = nil, template: nil) ⇒ Array<NilClass>

    Parameters:

    • element_class (Class<Magicka::Element>)

      Class of the element to be rendered

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

      Name of the method that will render the element

    • template (String) (defaults to: nil)

      custom template file to be used

  • #with_element(element_class_name, method_name = nil, template: nil) ⇒ Array<NilClass>

    Parameters:

    • element_class_name (String)

      String representation of a class of Element of the element to be rendered

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

      Name of the method that will render the element

    • template (String) (defaults to: nil)

      custom template file to be used

Returns:

  • (Array<NilClass>)

See Also:



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

def with_element(element_class, method_name = nil, template: nil)
  MethodBuilder
    .new(self, element_class, method_name, template: template)
    .prepare
    .build
end