Class: PgEnum::ActiveRecord::ConnectionAdapters::TableDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_enum/active_record.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/pg_enum/active_record.rb', line 46

def method_missing(symbol, *args)
  if symbol.to_s == 'xml'
    xml_column_fallback(args)
  else
    if PostgreSQLAdapter::NATIVE_DATABASE_TYPES.has_key?(symbol)
        enum_column_fallback(symbol, args)
    else
      super
    end
  end
end

Instance Method Details

#enum_column_fallback(type, *args) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/pg_enum/active_record.rb', line 58

def enum_column_fallback(type, *args)
  case @base.adapter_name.downcase
  when 'postgresql'
    options = args.extract_options!
    column(args[0], type, options)
  end
end