Class: Magicka::Aggregator::MethodBuilder Private
- Inherits:
-
Sinclair
- Object
- Sinclair
- Magicka::Aggregator::MethodBuilder
- 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 Attribute Summary collapse
-
#template ⇒ String
readonly
private
Template file.
Instance Method Summary collapse
-
#element_class ⇒ Class<Magicka::Element>
private
Class of the element to be rendered by the method.
-
#initialize(klass, element_class, method_name = nil, template: nil) ⇒ MethodBuilder
constructor
private
A new instance of MethodBuilder.
-
#prepare ⇒ Aggregator::MethodBuilder
private
Prepare methods to be built.
Constructor Details
#initialize(klass, element_class, method_name = nil, template: nil) ⇒ MethodBuilder #initialize(klass, element_class_name, method_name = nil, template: 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.
26 27 28 29 30 31 32 |
# File 'lib/magicka/aggregator/method_builder.rb', line 26 def initialize(klass, element_class, method_name = nil, template: nil) super(klass) @element_class = element_class @method_name = method_name @template = template end |
Instance Attribute Details
#template ⇒ String (readonly)
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.
Template file
64 65 66 |
# File 'lib/magicka/aggregator/method_builder.rb', line 64 def template @template end |
Instance Method Details
#element_class ⇒ Class<Magicka::Element>
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.
Class of the element to be rendered by the method
52 53 54 55 56 |
# File 'lib/magicka/aggregator/method_builder.rb', line 52 def element_class return @element_class if @element_class.is_a?(Class) @element_class = @element_class.constantize end |
#prepare ⇒ Aggregator::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.
Prepare methods to be built
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/magicka/aggregator/method_builder.rb', line 37 def prepare tap do |builder| add_method(method_name) do |field, model: self.model, **args| builder.element_class.render( renderer: renderer, field: field, model: model, template: builder.template, **args ) end end end |