Class: Mautic::Tag::Collection
- Inherits:
-
Array
- Object
- Array
- Mautic::Tag::Collection
- Defined in:
- app/models/mautic/tag.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #<<(item) ⇒ Object
-
#initialize(model, *several_variants) ⇒ Collection
constructor
A new instance of Collection.
- #remove(item) ⇒ Object
- #to_mautic ⇒ Object
Constructor Details
#initialize(model, *several_variants) ⇒ Collection
Returns a new instance of Collection.
8 9 10 11 12 |
# File 'app/models/mautic/tag.rb', line 8 def initialize(model, *several_variants) @model = model @tags_to_remove = [] super(several_variants) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'app/models/mautic/tag.rb', line 5 def model @model end |
Instance Method Details
#<<(item) ⇒ Object
14 15 16 17 18 |
# File 'app/models/mautic/tag.rb', line 14 def <<(item) @model.changed = true item = Tag.new(@model, { tag: item }) if item.is_a?(String) super(item) end |
#remove(item) ⇒ Object
20 21 22 23 24 25 |
# File 'app/models/mautic/tag.rb', line 20 def remove(item) @model.changed = true item = detect { |t| t.name == item } if item.is_a?(String) @tags_to_remove << "-#{item}" delete item end |
#to_mautic ⇒ Object
27 28 29 |
# File 'app/models/mautic/tag.rb', line 27 def to_mautic map(&:name) + @tags_to_remove end |