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.
48 49 50 51 |
# File 'lib/magicka/aggregator.rb', line 48 def initialize(renderer, model) @renderer = renderer @model = model end |
Instance Attribute Details
#model ⇒ String (readonly)
Model where the form elements will focus
14 15 16 |
# File 'lib/magicka/aggregator.rb', line 14 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 21
|
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
97 98 99 100 101 102 |
# File 'lib/magicka/aggregator.rb', line 97 def equal?(other) return 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
85 86 87 88 89 |
# File 'lib/magicka/aggregator.rb', line 85 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
74 75 76 77 78 |
# File 'lib/magicka/aggregator.rb', line 74 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
63 64 65 66 67 |
# File 'lib/magicka/aggregator.rb', line 63 def with_model(model, base: self.model) new_model = [base, model].compact.join('.') yield self.class.new(renderer, new_model) end |