Class: Mobility::Backends::ActiveRecord::Container::Coder

Inherits:
Object
  • Object
show all
Defined in:
lib/mobility/backends/active_record/container.rb

Class Method Summary collapse

Class Method Details

.dump(obj) ⇒ Object


124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/mobility/backends/active_record/container.rb', line 124

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

.load(obj) ⇒ Object


137
138
139
# File 'lib/mobility/backends/active_record/container.rb', line 137

def self.load(obj)
  obj
end