Module: Zena::Use::Grid::Common

Included in:
ControllerMethods, ViewMethods
Defined in:
lib/zena/use/grid.rb

Instance Method Summary collapse

Instance Method Details

#get_table_from_json(text) ⇒ Object

Build a tabular content from a node’s attribute

Raises:

  • (JSON::ParserError)


10
11
12
13
14
15
16
17
18
19
# File 'lib/zena/use/grid.rb', line 10

def get_table_from_json(text)
  if text.blank?
    table = [{"type"=>"table"},[["title"],["value"]]]
  else
    table = JSON.parse(text)
  end

  raise JSON::ParserError unless table.kind_of?(Array) && table.size == 2 && table[0].kind_of?(Hash) && table[0]['type'] == 'table' && table[1].kind_of?(Array)
  table
end