Sha256: 6f97f1e23fa1ccba590600ff9f9a31f42dbd2fc2cfa379a7db57dbfe25249f84

Contents?: true

Size: 942 Bytes

Versions: 5

Compression:

Stored size: 942 Bytes

Contents

module HasMachineTags
  # Methods for console/irb use.
  module Console
    module InstanceMethods
      # Removes first list, adds second list and saves changes.
      def tag_add_and_remove(remove_list, add_list)
        self.class.transaction do
          tag_add_and_save(add_list)
          tag_remove_and_save(remove_list)
        end
      end

      # Adds given list and saves.
      def tag_add_and_save(add_list)
        self.tag_list = self.tag_list + current_tag_list(add_list)
        self.save
        self.tag_list
      end
      
      # Removes given list and saves.
      def tag_remove_and_save(remove_list)
        self.tag_list = self.tag_list - current_tag_list(remove_list)
        self.save
        self.tag_list
      end
      
      # Resets tag_list to given tag_list and saves.
      def tag_and_save(tag_list)
        self.tag_list = tag_list
        self.save
        self.tag_list
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
has_machine_tags-0.2.2 lib/has_machine_tags/console.rb
has_machine_tags-0.2.1 lib/has_machine_tags/console.rb
has_machine_tags-0.2.0 lib/has_machine_tags/console.rb
has_machine_tags-0.1.8 lib/has_machine_tags/console.rb
has_machine_tags-0.1.7 lib/has_machine_tags/console.rb