Module: Crudboy::Extension

Extended by:
ActiveSupport::Concern
Defined in:
lib/crudboy/definition.rb

Instance Method Summary collapse

Instance Method Details

#tObject



6
7
8
9
10
# File 'lib/crudboy/definition.rb', line 6

def t
  puts Terminal::Table.new { |t|
    v.each { |row| t << (row || :separator) }
  }
end

#to_insert_sqlObject



22
23
24
# File 'lib/crudboy/definition.rb', line 22

def to_insert_sql
  self.class.to_insert_sql([self])
end

#to_upsert_sqlObject



26
27
28
# File 'lib/crudboy/definition.rb', line 26

def to_upsert_sql
  self.class.to_upsert_sql([self])
end

#vObject



12
13
14
15
16
17
18
19
20
# File 'lib/crudboy/definition.rb', line 12

def v
  t = []
  t << ['Attribute Name', 'Attribute Value', 'SQL Type', 'Comment']
  t << nil
  self.class.connection.columns(self.class.table_name).each do |column|
    t << [column.name, read_attribute(column.name), column.sql_type, column.comment || '']
  end
  t
end

#write_csv(filename, *fields, **options) ⇒ Object



30
31
32
# File 'lib/crudboy/definition.rb', line 30

def write_csv(filename, *fields, **options)
  [self].write_csv(filename, *fields, **options)
end

#write_excel(filename, *fields, **options) ⇒ Object



34
35
36
# File 'lib/crudboy/definition.rb', line 34

def write_excel(filename, *fields, **options)
  [self].write_excel(filename, *fields, **options)
end