Module: Crudboy::Extension
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/crudboy/definition.rb
Instance Method Summary collapse
- #t ⇒ Object
- #to_insert_sql ⇒ Object
- #to_upsert_sql ⇒ Object
- #v ⇒ Object
- #write_csv(filename, *fields, **options) ⇒ Object
- #write_excel(filename, *fields, **options) ⇒ Object
Instance Method Details
#t ⇒ Object
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_sql ⇒ Object
22 23 24 |
# File 'lib/crudboy/definition.rb', line 22 def to_insert_sql self.class.to_insert_sql([self]) end |
#to_upsert_sql ⇒ Object
26 27 28 |
# File 'lib/crudboy/definition.rb', line 26 def to_upsert_sql self.class.to_upsert_sql([self]) end |
#v ⇒ Object
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, **) [self].write_csv(filename, *fields, **) end |
#write_excel(filename, *fields, **options) ⇒ Object
34 35 36 |
# File 'lib/crudboy/definition.rb', line 34 def write_excel(filename, *fields, **) [self].write_excel(filename, *fields, **) end |