Class: Mobility::Backend::ActiveRecord::HashValued::Coder

Inherits:
Object
  • Object
show all
Defined in:
lib/mobility/backend/active_record/hash_valued.rb

Class Method Summary collapse

Class Method Details

.dump(obj) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/mobility/backend/active_record/hash_valued.rb', line 41

def self.dump(obj)
  if obj.is_a? Hash
    obj = obj.inject({}) do |translations, (locale, value)|
      translations[locale] = value if value.present?
      translations
    end
  else
    raise ArgumentError, "Attribute is supposed to be a Hash, but was a #{obj.class}. -- #{obj.inspect}"
  end
end

.load(obj) ⇒ Object



52
53
54
# File 'lib/mobility/backend/active_record/hash_valued.rb', line 52

def self.load(obj)
  obj
end