Class: Txdb::Backends::Globalize::Writer

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/txdb/backends/globalize/writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#origin_table_name, #resource_slug_for

Constructor Details

#initialize(table) ⇒ Writer

Returns a new instance of Writer.



12
13
14
# File 'lib/txdb/backends/globalize/writer.rb', line 12

def initialize(table)
  @table = table
end

Instance Attribute Details

#tableObject (readonly)

Returns the value of attribute table.



10
11
12
# File 'lib/txdb/backends/globalize/writer.rb', line 10

def table
  @table
end

Instance Method Details

#write_content(resource, locale) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/txdb/backends/globalize/writer.rb', line 16

def write_content(resource, locale)
  content = deserialize_content(resource.content)
  content = content.fetch(origin_table_name(table.name), {})

  content.each_pair do |id, fields|
    update_row(id, fields, locale)
  end
end