class ActiveFacts::RMap::Column

Public Instance Methods

is_auto_timestamp() click to toggle source
# File lib/activefacts/generators/rails/models.rb, line 235
def is_auto_timestamp
  case name('_')
  when /\A(created|updated)_(at|on)\Z/i
    true
  else
    false
  end
end
is_injected_surrogate() click to toggle source
# File lib/activefacts/generators/transform/surrogate.rb, line 184
def is_injected_surrogate
  references.size == 1 and
    references[0].from_role == references[0].from.injected_surrogate_role
end
rails_name() click to toggle source
# File lib/activefacts/generators/traits/rails.rb, line 36
def rails_name
  RMap::rails_singular_name(name('_'))
end
rails_type() click to toggle source
# File lib/activefacts/generators/traits/rails.rb, line 40
def rails_type
  type_name, params, constraints = *type()
  rails_type = case type_name
    when /^Auto ?Counter$/i
      'serial'        # REVISIT: Need to detect surrogate ID fields and handle them correctly

    when /^[Ug]uid$/i
      'uuid'

    when /^Unsigned ?Integer$/i,
      /^Integer$/i,
      /^Signed ?Integer$/i,
      /^Unsigned ?Small ?Integer$/i,
      /^Signed ?Small ?Integer$/i,
      /^Unsigned ?Tiny ?Integer$/i
      length = nil
      'integer'

    when /^Decimal$/i
      'decimal'

    when /^Float$/i, /^Double$/i, /^Real$/i
      'float'

    when /^Fixed ?Length ?Text$/i, /^Char$/i
      'string'
    when /^Variable ?Length ?Text$/i, /^String$/i
      'string'
    when /^Large ?Length ?Text$/i, /^Text$/i
      'text'

    when /^Date ?And ?Time$/i, /^Date ?Time$/i
      'datetime'
    when /^Date$/i
      'datetime'
    when /^Time$/i
      'time'
    when /^Auto ?Time ?Stamp$/i
      'timestamp'

    when /^Money$/i
      'decimal'
    when /^Picture ?Raw ?Data$/i, /^Image$/i, /^Variable ?Length ?Raw ?Data$/i, /^Blob$/i
      'binary'
    when /^BIT$/i, /^Boolean$/i
      'boolean'
    else
      type_name # raise "ActiveRecord type unknown for standard type #{type}"
    end
  [rails_type, params[:length]]
end