Class: Magicka::Aggregator
- Inherits:
-
Object
- Object
- Magicka::Aggregator
- Extended by:
- ClassMethods
- Defined in:
- lib/magicka/aggregator.rb,
lib/magicka/aggregator/class_methods.rb,
lib/magicka/aggregator/method_builder.rb
Overview
Class representing an element agregator, representing a model
Defined Under Namespace
Modules: ClassMethods Classes: MethodBuilder
Instance Attribute Summary collapse
-
#model ⇒ String
readonly
Model where the form elements will focus.
Class Method Summary collapse
-
.with_element(element_class, method_name = nil, template: nil) ⇒ Array<NilClass>
Configure an Aggregator adding a method to render an element.
Instance Method Summary collapse
-
#equal?(other) ⇒ TrueClass, FalseClass
(also: #==)
private
Checks if other aggragate is equal to this one.
-
#except(*types) ⇒ Object
Executes a block only when aggregator is not one of given types.
-
#initialize(renderer, model) ⇒ Aggregator
constructor
A new instance of Aggregator.
-
#only(*types) ⇒ Object
Executes a block only when aggregator is one of given types.
-
#with_model(model, base: self.model) {|Aggregator| ... } ⇒ Aggregator
Returns a new aggregator focusing on a new model.
Methods included from ClassMethods
Constructor Details
#initialize(renderer, model) ⇒ Aggregator
Returns a new instance of Aggregator.
49 50 51 52 |
# File 'lib/magicka/aggregator.rb', line 49 def initialize(renderer, model) @renderer = renderer @model = model end |
Instance Attribute Details
#model ⇒ String (readonly)
Model where the form elements will focus
15 16 17 |
# File 'lib/magicka/aggregator.rb', line 15 def model @model end |
Class Method Details
.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
|
|
# File 'lib/magicka/aggregator.rb', line 22
|
Instance Method Details
#equal?(other) ⇒ TrueClass, FalseClass Also known as: ==
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.
Checks if other aggragate is equal to this one
98 99 100 101 102 103 |
# File 'lib/magicka/aggregator.rb', line 98 def equal?(other) return false unless other.class == self.class other.renderer == renderer && other.model == model end |
#except(*types) ⇒ Object
Executes a block only when aggregator is not one of given types
86 87 88 89 90 |
# File 'lib/magicka/aggregator.rb', line 86 def except(*types) return if types.include?(self.class.type) yield end |
#only(*types) ⇒ Object
Executes a block only when aggregator is one of given types
75 76 77 78 79 |
# File 'lib/magicka/aggregator.rb', line 75 def only(*types) return unless types.include?(self.class.type) yield end |
#with_model(model, base: self.model) {|Aggregator| ... } ⇒ Aggregator
Returns a new aggregator focusing on a new model
The new model is an attribute of model unless base is given
64 65 66 67 68 |
# File 'lib/magicka/aggregator.rb', line 64 def with_model(model, base: self.model) new_model = [base, model].compact.join('.') yield self.class.new(renderer, new_model) end |