Sha256: 7ee2d444ccff3fa2ee798f5573e9b63177b4a8df6272be0ef69ea30c4ca1aff4

Contents?: true

Size: 797 Bytes

Versions: 7

Compression:

Stored size: 797 Bytes

Contents

module Rewritten
  module Document


    def rewritten_url
      return "" unless persisted? 
      Rewritten.get_current_translation(polymorphic_url(self, :only_path => true))
    end

    def rewritten_url=(new_url)
      if !new_url.nil? && new_url != "" && new_url != rewritten_url
        Rewritten.add_translation(new_url, polymorphic_url(self, :only_path => true)) 
      end
    end

    def rewritten_urls
      return [] unless persisted? 
      Rewritten.get_all_translations(polymorphic_url(self, :only_path => true))
    end

    def has_rewritten_url?
      Rewritten.exist_translation_for?(polymorphic_url(self, :only_path => true))
    end
    
    def remove_rewritten_urls
      Rewritten.remove_all_translations(polymorphic_url(self, :only_path => true))
    end
    
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rewritten-0.15.0 lib/rewritten/document.rb
rewritten-0.14.2 lib/rewritten/document.rb
rewritten-0.14.1 lib/rewritten/document.rb
rewritten-0.14.0 lib/rewritten/document.rb
rewritten-0.13.1 lib/rewritten/document.rb
rewritten-0.13.0 lib/rewritten/document.rb
rewritten-0.12.1 lib/rewritten/document.rb