class Crudboy::Column

Constants

JAVA_TYPES
JDBC_TYPES

Attributes

active_record_column[RW]
primary[RW]

Public Class Methods

new(column, primary) click to toggle source
# File lib/crudboy/column.rb, line 30
def initialize(column, primary)
  @active_record_column = column
  @primary = primary
end

Public Instance Methods

java_doc() click to toggle source
# File lib/crudboy/column.rb, line 35
    def java_doc
      <<-EOF.lstrip.chomp
      /**
     * #{comment}
     */
      EOF
    end
java_type() click to toggle source
# File lib/crudboy/column.rb, line 67
def java_type
  return 'Boolean' if sql_type == 'tinyint(1)'
  raw_type = sql_type.scan(/^\w+/).first
  JAVA_TYPES[raw_type]
end
jdbc_type() click to toggle source
# File lib/crudboy/column.rb, line 73
def jdbc_type
  raw_type = sql_type.scan(/^\w+/).first
  JDBC_TYPES[raw_type]
end
lower_camel_name() click to toggle source
# File lib/crudboy/column.rb, line 59
def lower_camel_name
  name.camelcase(:lower)
end
method_missing(method, *args, **options, &block) click to toggle source
Calls superclass method
# File lib/crudboy/column.rb, line 78
def method_missing(method, *args, **options, &block)
  if active_record_column.respond_to?(method)
    active_record_column.send(method, *args, **options, &block)
  else
    super
  end
end
mybatis_equation() click to toggle source
# File lib/crudboy/column.rb, line 47
def mybatis_equation
  format('`%s` = %s', name, mybatis_value_expression)
end
mybatis_result_map() click to toggle source
# File lib/crudboy/column.rb, line 51
def mybatis_result_map
  if @primary
    format('<id column="%s" jdbcType="%s" property="%s" />', name, jdbc_type, lower_camel_name)
  else
    format('<result column="%s" jdbcType="%s" property="%s" />', name, jdbc_type, lower_camel_name)
  end
end
mybatis_value_expression() click to toggle source
# File lib/crudboy/column.rb, line 43
def mybatis_value_expression
  format('#{%s,jdbcType=%s}', lower_camel_name, jdbc_type)
end
upper_camel_name() click to toggle source
# File lib/crudboy/column.rb, line 63
def upper_camel_name
  name.camelcase(:upper)
end