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.
Backend Accessors collapse
- .build_op(attr, locale) ⇒ Object
-
#each_locale {|Locale| ... } ⇒ Object
Yields locales available for this attribute.
-
#read(locale, _options = nil) ⇒ Object
Gets the translated value for provided locale from configured backend.
-
#write(locale, value, _options = nil) ⇒ Object
Updates translation for provided locale without calling backend’s methods to persist the changes.
Methods included from Column
Methods included from Mobility::Backends::Sequel
Class Method Details
.build_op(attr, locale) ⇒ Object
35 36 37 38 |
# File 'lib/mobility/backends/sequel/column.rb', line 35 def self.build_op(attr, locale) ::Sequel::SQL::QualifiedIdentifier.new(model_class.table_name, Column.column_name_for(attr, locale)) end |
Instance Method Details
#each_locale {|Locale| ... } ⇒ Object
Yields locales available for this attribute.
31 32 33 |
# File 'lib/mobility/backends/sequel/column.rb', line 31 def each_locale available_locales.each { |l| yield(l) if present?(l) } end |
#read(locale, _options = nil) ⇒ Object
Gets the translated value for provided locale from configured backend.
18 19 20 21 |
# File 'lib/mobility/backends/sequel/column.rb', line 18 def read(locale, = nil) column = column(locale) model[column] if model.columns.include?(column) end |
#write(locale, value, _options = nil) ⇒ Object
Updates translation for provided locale without calling backend’s methods to persist the changes.
25 26 27 28 |
# File 'lib/mobility/backends/sequel/column.rb', line 25 def write(locale, value, = nil) column = column(locale) model[column] = value if model.columns.include?(column) end |