Module: Rewritten::Document
- Includes:
- ActiveSupport::Inflector
- Defined in:
- lib/rewritten/document.rb
Instance Method Summary collapse
- #path ⇒ Object
- #remove_rewritten_urls ⇒ Object
- #rewritten_url ⇒ Object
- #rewritten_url=(new_url) ⇒ Object
- #rewritten_url? ⇒ Boolean
- #rewritten_urls ⇒ Object
Instance Method Details
#path ⇒ Object
7 8 9 10 11 |
# File 'lib/rewritten/document.rb', line 7 def path plural = ActiveSupport::Inflector.pluralize(self.class.to_s) resources = ActiveSupport::Inflector.underscore(plural) "/#{resources}/#{id}" end |
#remove_rewritten_urls ⇒ Object
33 34 35 |
# File 'lib/rewritten/document.rb', line 33 def remove_rewritten_urls Rewritten.remove_all_translations(path) end |
#rewritten_url ⇒ Object
13 14 15 16 |
# File 'lib/rewritten/document.rb', line 13 def rewritten_url return '' unless persisted? Rewritten.get_current_translation(path) end |
#rewritten_url=(new_url) ⇒ Object
18 19 20 21 22 |
# File 'lib/rewritten/document.rb', line 18 def rewritten_url=(new_url) if !new_url.nil? && new_url != '' && new_url != rewritten_url Rewritten.add_translation(new_url, path) end end |
#rewritten_url? ⇒ Boolean
29 30 31 |
# File 'lib/rewritten/document.rb', line 29 def rewritten_url? Rewritten.exist_translation_for?(path) end |
#rewritten_urls ⇒ Object
24 25 26 27 |
# File 'lib/rewritten/document.rb', line 24 def rewritten_urls return [] unless persisted? Rewritten.get_all_translations(path) end |