Class: Mobility::Backend::Sequel::HashValued

Inherits:
Object
  • Object
show all
Includes:
Mobility::Backend
Defined in:
lib/mobility/backend/sequel/hash_valued.rb

Overview

Internal class used by Sequel backends that store values as a hash.

Direct Known Subclasses

Hstore, Jsonb

Instance Attribute Summary

Attributes included from Mobility::Backend

#attribute, #model, #options

Cache Methods collapse

Instance Method Summary collapse

Methods included from Mobility::Backend

included, #initialize, method_name

Instance Method Details

#read(locale, **options) ⇒ Object

Returns Value of translation.

Parameters:

  • locale (Symbol)

    Locale to read

  • options (Hash)

Returns:

  • (Object)

    Value of translation



12
13
14
# File 'lib/mobility/backend/sequel/hash_valued.rb', line 12

def read(locale, **options)
  translations[locale.to_s]
end

#translationsObject Also known as: new_cache



22
23
24
# File 'lib/mobility/backend/sequel/hash_valued.rb', line 22

def translations
  model.send("#{attribute}_before_mobility")
end

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

Returns Updated value.

Parameters:

  • locale (Symbol)

    Locale to write

  • value (Object)

    Value to write

  • options (Hash)

Returns:



17
18
19
# File 'lib/mobility/backend/sequel/hash_valued.rb', line 17

def write(locale, value, **options)
  translations[locale.to_s] = value
end

#write_to_cache?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/mobility/backend/sequel/hash_valued.rb', line 28

def write_to_cache?
  true
end