Sha256: 07f10d2284550ca8d84151b69b3ddcb2c7d31dcd874aa51e687bb21ebd924039

Contents?: true

Size: 1.16 KB

Versions: 19

Compression:

Stored size: 1.16 KB

Contents

module ActsAsTaggableOn::Taggable
  module Dirty
    def self.included(base)
      base.extend ActsAsTaggableOn::Taggable::Dirty::ClassMethods

      base.initialize_acts_as_taggable_on_dirty
    end

    module ClassMethods
      def initialize_acts_as_taggable_on_dirty
        tag_types.map(&:to_s).each do |tags_type|
          tag_type         = tags_type.to_s.singularize

          class_eval <<-RUBY, __FILE__, __LINE__ + 1
            def #{tag_type}_list_changed?
              changed_attributes.include?("#{tag_type}_list")
            end

            def #{tag_type}_list_was
              changed_attributes.include?("#{tag_type}_list") ? changed_attributes["#{tag_type}_list"] : __send__("#{tag_type}_list")
            end

            def #{tag_type}_list_change
              [changed_attributes['#{tag_type}_list'], __send__('#{tag_type}_list')] if changed_attributes.include?("#{tag_type}_list")
            end

            def #{tag_type}_list_changes
              [changed_attributes['#{tag_type}_list'], __send__('#{tag_type}_list')] if changed_attributes.include?("#{tag_type}_list")
            end
          RUBY

        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
acts-as-taggable-on-5.0.0 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-4.0.0 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-4.0.0.pre lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.5.0 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.4.4 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.4.3 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.4.2 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.4.1 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.4.0 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.3.0 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.2.6 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.2.5 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.2.4 lib/acts_as_taggable_on/taggable/dirty.rb
acts-as-taggable-on-3.2.3 lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb
acts-as-taggable-on-3.2.2 lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb
acts-as-taggable-on-3.2.1 lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb
acts-as-taggable-on-3.1.1 lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb
acts-as-taggable-on-3.1.0 lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb
acts-as-taggable-on-3.1.0.rc1 lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb