Class Index [+]

Quicksearch

ArJdbc::SQLite3::Column

Public Instance Methods

init_column(name, default, *args) click to toggle source
    # File lib/arjdbc/sqlite3/adapter.rb, line 18
18:       def init_column(name, default, *args)
19:         @default = '' if default =~ /NULL/
20:       end
type_cast(value) click to toggle source
    # File lib/arjdbc/sqlite3/adapter.rb, line 22
22:       def type_cast(value)
23:         return nil if value.nil?
24:         case type
25:         when :string   then value
26:         when :primary_key then defined?(value.to_i) ? value.to_i : (value ? 1 : 0)
27:         when :float    then value.to_f
28:         when :decimal  then self.class.value_to_decimal(value)
29:         when :boolean  then self.class.value_to_boolean(value)
30:         else super
31:         end
32:       end

Private Instance Methods

default_value(value) click to toggle source

Post process default value from JDBC into a Rails-friendly format (columns{-internal})

    # File lib/arjdbc/sqlite3/adapter.rb, line 66
66:       def default_value(value)
67:         # jdbc returns column default strings with actual single quotes around the value.
68:         return $1 if value =~ /^'(.*)'$/
69: 
70:         value
71:       end
extract_precision(sql_type) click to toggle source
    # File lib/arjdbc/sqlite3/adapter.rb, line 50
50:       def extract_precision(sql_type)
51:         case sql_type
52:           when /^(real)\((\d+)(,\d+)?\)/ then $2.to_i
53:           else super
54:         end
55:       end
extract_scale(sql_type) click to toggle source
    # File lib/arjdbc/sqlite3/adapter.rb, line 57
57:       def extract_scale(sql_type)
58:         case sql_type
59:           when /^(real)\((\d+)\)/ then 0
60:           when /^(real)\((\d+)(,(\d+))\)/ then $4.to_i
61:           else super
62:         end
63:       end
simplified_type(field_type) click to toggle source
    # File lib/arjdbc/sqlite3/adapter.rb, line 35
35:       def simplified_type(field_type)
36:         case field_type
37:         when /boolean/                        then :boolean
38:         when /text/                           then :text
39:         when /varchar/                        then :string
40:         when /int/                            then :integer
41:         when /float/                          then :float
42:         when /real/                           then @scale == 0 ? :integer : :decimal
43:         when /datetime/                       then :datetime
44:         when /date/                           then :date
45:         when /time/                           then :time
46:         when /blob/                           then :binary
47:         end
48:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.