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



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/mobility/backends/active_record/container.rb', line 121

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



134
135
136
# File 'lib/mobility/backends/active_record/container.rb', line 134

def self.load(obj)
  obj
end