module Miguel::Schema::Output
Module for pretty printing of names, types, and especially options.
Public Instance Methods
out_canonic_opts( prefix = ', ' )
click to toggle source
# File lib/miguel/schema.rb, line 47 def out_canonic_opts( prefix = ', ' ) out_hash( canonic_opts, prefix ) end
out_columns()
click to toggle source
# File lib/miguel/schema.rb, line 63 def out_columns columns.inspect end
out_default()
click to toggle source
# File lib/miguel/schema.rb, line 71 def out_default out_value(default) end
out_default_opts( prefix = ', ' )
click to toggle source
# File lib/miguel/schema.rb, line 51 def out_default_opts( prefix = ', ' ) out_hash( default_opts, prefix ) end
out_name()
click to toggle source
# File lib/miguel/schema.rb, line 55 def out_name name.inspect end
out_opts( prefix = ', ' )
click to toggle source
# File lib/miguel/schema.rb, line 43 def out_opts( prefix = ', ' ) out_hash( opts, prefix ) end
out_table_name()
click to toggle source
# File lib/miguel/schema.rb, line 67 def out_table_name table_name.inspect end
out_type()
click to toggle source
# File lib/miguel/schema.rb, line 59 def out_type type.to_s =~ /\A[A-Z]/ ? type.to_s : type.inspect end
Private Instance Methods
out_hash( value, prefix = ', ' )
click to toggle source
# File lib/miguel/schema.rb, line 36 def out_hash( value, prefix = ', ' ) return "" if value.empty? prefix.dup << value.map{ |k,v| "#{out_value( k )} => #{out_value( v )}" }.join( ', ' ) end
out_value( value )
click to toggle source
# File lib/miguel/schema.rb, line 23 def out_value( value ) case value when Hash "{#{ value.map{ |k,v| "#{out_value( k )} => #{out_value( v )}" }.join( ', ' ) }}" when Array "[#{ value.map{ |v| out_value( v ) }.join( ', ' ) }]" when Sequel::LiteralString "Sequel.lit(#{value.to_s.inspect})" else value.inspect end end