Sha256: a63195f4bad45cf59efa4c124e623b0e14633b11b1eee920000f670035e08dac

Contents?: true

Size: 712 Bytes

Versions: 8

Compression:

Stored size: 712 Bytes

Contents

module Spud::LiquidTaggable
	extend ActiveSupport::Concern
	included do
		extend ClassMethods
	end
	module ClassMethods
		def liquid_taggable(options)
			@liquid_tag_name = options[:tag_name]
			@liquid_tag_id_field = options[:tag_id_field] || :name
		  after_save :expire_cache
		  after_destroy :expire_cache
		end
	end

  def expire_cache
    # Now Time to Update Parent Entries
    old_name = self.name_was
    values = [self.name]
    values << old_name if !old_name.blank?
    SpudPageLiquidTag.where(:tag_name => "snippet",:value => values).includes(:attachment).each do |tag|
      partial = tag.touch
    end
  end

  def tag_name
    	self.superclass.instance_variable_get('@liquid_tag_name')
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spud_cms-1.0.2 lib/spud_cms/liquid_taggable.rb
spud_cms-1.0.1 lib/spud_cms/liquid_taggable.rb
spud_cms-1.0.0 lib/spud_cms/liquid_taggable.rb
spud_cms-1.0.0.rc1.4 lib/spud_cms/liquid_taggable.rb
spud_cms-1.0.0.rc1.3 lib/spud_cms/liquid_taggable.rb
spud_cms-1.0.0.rc1.2 lib/spud_cms/liquid_taggable.rb
spud_cms-1.0.0.rc1.1 lib/spud_cms/liquid_taggable.rb
spud_cms-1.0.0.RC1 lib/spud_cms/liquid_taggable.rb