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
- #do_action(attrs) ⇒ Object
-
#initialize(parent) ⇒ TagsCollection
constructor
A new instance of TagsCollection.
- #remove!(*tag_names) ⇒ Object
- #update_parent ⇒ Object
Constructor Details
#initialize(parent) ⇒ TagsCollection
Returns a new instance of 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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 17 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 @all += update_parent end |
#all ⇒ Object
11 12 13 14 15 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 11 def all return @all if defined? @all @all = @parent.tn.to_s.split(',') end |
#do_action(attrs) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 59 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.soap_connector.invoke(soap_request) end |
#remove!(*tag_names) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 36 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 @all -= tag_names update_parent end |
#update_parent ⇒ Object
55 56 57 |
# File 'lib/zm/client/tag/account_object_tags_collection.rb', line 55 def update_parent @parent.tn = @all.join(',') end |