Class: Mobility::Backend::ActiveRecord::Column

Inherits:
Object
  • Object
show all
Includes:
Mobility::Backend, Column
Defined in:
lib/mobility/backend/active_record/column.rb

Overview

Note:

This backend disables the accessor_locales option, which would otherwise interfere with column methods.

Implements the Column backend for ActiveRecord models.

Examples:

class Post < ActiveRecord::Base
  translates :title, backend: :column
end

Mobility.locale = :en
post = Post.create(title: "foo")
post.title
#=> "foo"
post.title_en
#=> "foo"

Defined Under Namespace

Classes: QueryMethods

Instance Attribute Summary

Attributes included from Mobility::Backend

#attribute, #model, #options

Backend Accessors collapse

Backend Configuration collapse

Methods included from Column

#column, column_name_for

Methods included from OrmDelegator

#for, included

Methods included from Mobility::Backend

included, #initialize, method_name

Class Method Details

.configure!(options) ⇒ Object



37
38
39
# File 'lib/mobility/backend/active_record/column.rb', line 37

def self.configure!(options)
  options[:locale_accessors] = false
end

Instance Method Details

#read(locale, **options) ⇒ Object

Returns Value of translation.

Parameters:

  • locale (Symbol)

    Locale to read

  • options (Hash)

Returns:

  • (Object)

    Value of translation



# File 'lib/mobility/backend/active_record/column.rb', line 28

#write(locale, value, **options) ⇒ Object

Returns Updated value.

Parameters:

  • locale (Symbol)

    Locale to write

  • value (Object)

    Value to write

  • options (Hash)

Returns:



# File 'lib/mobility/backend/active_record/column.rb', line 32