Class: Zm::Client::AccountObject::TagsCollection
- Inherits:
-
Object
- Object
- Zm::Client::AccountObject::TagsCollection
- Defined in:
- lib/zm/client/tag/account_object_tags_collection.rb
Instance Method Summary collapse
- #add!(*new_tags) ⇒ Object
- #all ⇒ Object
- #all! ⇒ Object
- #do_action(attrs) ⇒ Object
-
#initialize(parent) ⇒ TagsCollection
constructor
A new instance of TagsCollection.
- #remove!(*tag_names) ⇒ Object
Constructor Details
#initialize(parent) ⇒ TagsCollection
7 8 9 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 7 def initialize(parent) @parent = parent end |
Instance Method Details
#add!(*new_tags) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 19 def add!(*) .flatten! Utils.map_format(, String, :name) return false if .delete_if { |tag_name| all.include?(tag_name) }.empty? .each do |tag_name| attrs = { op: :tag, id: @parent.id, tn: tag_name } do_action(attrs) end @parent.tn += all! end |
#all ⇒ Object
11 12 13 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 11 def all @all || all! end |
#all! ⇒ Object
15 16 17 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 15 def all! @all = @parent.tn.split(',') end |
#do_action(attrs) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 57 def do_action(attrs) soap_request = SoapElement.mail(SoapMailConstants::ITEM_ACTION_REQUEST) node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs) soap_request.add_node(node_action) @parent.parent.sacc.invoke(soap_request) end |
#remove!(*tag_names) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 38 def remove!(*tag_names) tag_names.flatten! Utils.map_format(tag_names, String, :name) return false if tag_names.delete_if { |tag_name| !all.include?(tag_name) }.empty? tag_names.each do |tag_name| attrs = { op: '!tag', id: @parent.id, tn: tag_name } do_action(attrs) end @parent.tn -= tag_names all! end |