class ApkgToCsv::Model
Attributes
id[R]
model_hash[R]
Public Class Methods
from_db(db)
click to toggle source
# File lib/apkg_to_csv/model.rb, line 6 def self.from_db(db) db.execute('SELECT models FROM col').flat_map do |row| from_row(row) end end
from_row(row)
click to toggle source
# File lib/apkg_to_csv/model.rb, line 12 def self.from_row(row) row.flat_map do |models_json| JSON.parse(models_json).map { |k, v| new(k, v) } end end
new(id, model_hash)
click to toggle source
# File lib/apkg_to_csv/model.rb, line 20 def initialize(id, model_hash) @id = id.to_s @model_hash = model_hash end
Public Instance Methods
fields()
click to toggle source
# File lib/apkg_to_csv/model.rb, line 25 def fields @fields ||= model_hash['flds'].map { |f| f['name'] } end