Class: Mobility::Backends::Sequel::Column
- Inherits:
-
Object
- Object
- Mobility::Backends::Sequel::Column
- Includes:
- Column, Mobility::Backends::Sequel
- Defined in:
- lib/mobility/backends/sequel/column.rb
Overview
Implements the Column backend for Sequel models.
Defined Under Namespace
Classes: QueryMethods
Backend Accessors collapse
-
#each_locale {|Locale| ... } ⇒ Object
Yields locales available for this attribute.
-
#read(locale, _ = {}) ⇒ Object
Gets the translated value for provided locale from configured backend.
-
#write(locale, value, _ = {}) ⇒ Object
Updates translation for provided locale without calling backend's methods to persist the changes.
Methods included from Column
#column, column_name_for, included
Methods included from Mobility::Backend::OrmDelegator
Methods included from Mobility::Backends::Sequel
included, #setup_query_methods
Instance Method Details
#each_locale {|Locale| ... } ⇒ Object
Yields locales available for this attribute.
32 33 34 |
# File 'lib/mobility/backends/sequel/column.rb', line 32 def each_locale available_locales.each { |l| yield(l) if present?(l) } end |
#read(locale, _ = {}) ⇒ Object
Gets the translated value for provided locale from configured backend.
19 20 21 22 |
# File 'lib/mobility/backends/sequel/column.rb', line 19 def read(locale, _ = {}) column = column(locale) model[column] if model.columns.include?(column) end |
#write(locale, value, _ = {}) ⇒ Object
Updates translation for provided locale without calling backend's methods to persist the changes.
26 27 28 29 |
# File 'lib/mobility/backends/sequel/column.rb', line 26 def write(locale, value, _ = {}) column = column(locale) model[column] = value if model.columns.include?(column) end |