Class: ActivePermalink::Localizer::PermalinkBackend
- Inherits:
-
Object
- Object
- ActivePermalink::Localizer::PermalinkBackend
- Defined in:
- lib/active_permalink/localizer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#permalinks ⇒ Object
readonly
Returns the value of attribute permalinks.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #exists?(locale) ⇒ Boolean
- #fallbacks? ⇒ Boolean
-
#initialize(record) ⇒ PermalinkBackend
constructor
A new instance of PermalinkBackend.
- #read(locale) ⇒ Object
- #write(value, locale, **options) ⇒ Object
Constructor Details
#initialize(record) ⇒ PermalinkBackend
Returns a new instance of PermalinkBackend.
43 44 45 46 47 |
# File 'lib/active_permalink/localizer.rb', line 43 def initialize(record) @record = record @options = record. @permalinks = record.permalinks.to_a end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
41 42 43 |
# File 'lib/active_permalink/localizer.rb', line 41 def @options end |
#permalinks ⇒ Object (readonly)
Returns the value of attribute permalinks.
41 42 43 |
# File 'lib/active_permalink/localizer.rb', line 41 def permalinks @permalinks end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
41 42 43 |
# File 'lib/active_permalink/localizer.rb', line 41 def record @record end |
Instance Method Details
#exists?(locale) ⇒ Boolean
53 54 55 56 |
# File 'lib/active_permalink/localizer.rb', line 53 def exists?(locale) enforce_available_locales!(locale) find_permalink(locale).present? end |
#fallbacks? ⇒ Boolean
49 50 51 |
# File 'lib/active_permalink/localizer.rb', line 49 def fallbacks? [:fallbacks].present? end |
#read(locale) ⇒ Object
58 59 60 61 |
# File 'lib/active_permalink/localizer.rb', line 58 def read(locale) enforce_available_locales!(locale) find_slug(locale) end |
#write(value, locale, **options) ⇒ Object
63 64 65 66 |
# File 'lib/active_permalink/localizer.rb', line 63 def write(value, locale, **) enforce_available_locales!(locale) update_slug(value, locale, **) end |