class Ryakuzu::SchemaService

Public Class Methods

new() click to toggle source
# File lib/ryakuzu/schema_parsing/schema_service.rb, line 5
def initialize
  @file        = File.open(Rails.root.join('db', 'schema.rb'))
  @schema_hash = Ryakuzu::Ripper.parse(file)
end

Public Instance Methods

call() click to toggle source
# File lib/ryakuzu/schema_parsing/schema_service.rb, line 10
def call
  schema_hash.each_with_object([]) { |schema, klass| klass << Ryakuzu::Table.generate_models(schema[0], schema[1]) }
end
schema_to_csv() click to toggle source
# File lib/ryakuzu/schema_parsing/schema_service.rb, line 14
def schema_to_csv
  CSV.open('schema.csv', 'wb') { |csv| schema_hash.to_a.map { |elem| csv << elem } }
end