Method: Mobility::Backend::ActiveRecord::HashValued::Coder.dump

Defined in:
lib/mobility/backend/active_record/hash_valued.rb

.dump(obj) ⇒ Object

[View source]

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