Sha256: 0e3cf163ceb938fbf1444d20b516ab15d62b39d0e138613a6954a43c226331bc

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

require 'active_record'
require 'active_record/base'
require 'active_record/connection_adapters/abstract/schema_definitions.rb'

require 'connection_adapters/sqlite3' if defined?( SQLite3 )
require 'connection_adapters/mysql2' if defined?( Mysql2 )

if ActiveRecord::VERSION::MAJOR < 4 || (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR <= 1)
  require 'native_enum/activerecord_enum_pre42.rb'
else
  require 'native_enum/activerecord_enum_post42.rb'
end

module ActiveRecord
  module ConnectionAdapters
    class TableDefinition
      def enum *args
        options = args.extract_options!
        column_names = args
        column_names.each { |name| column(name, :enum, options) }
      end
      def set *args
        options = args.extract_options!
        options[:default] = options[:default].join "," if options[:default].present?
        column_names = args
        column_names.each { |name| column(name, :set, options) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
native_enum-2.0.0 lib/native_enum.rb
native_enum-1.0.0 lib/native_enum.rb
native_enum-1.0.0pre1 lib/native_enum.rb