Sha256: 7076f3f258841e49a987c00d7d552bff612d5aa7b3ab0794b3ccf9901af093a8

Contents?: true

Size: 554 Bytes

Versions: 7

Compression:

Stored size: 554 Bytes

Contents

# frozen_string_literal: true

require 'rails_compatibility'
require 'rails_compatibility/active_record'

class << RailsCompatibility
  if ActiveRecord::Base.respond_to?(:attribute_types) # column_types was changed to attribute_types in Rails 5
    def attribute_types(klass)
      klass.attribute_types
    end
  elsif ActiveRecord::Base.respond_to?(:column_types) # Rails 4
    def attribute_types(klass)
      klass.column_types
    end
  else # In Rails 3
    def attribute_types(klass)
      klass.columns_hash
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_compatibility-0.0.10 lib/rails_compatibility/attribute_types.rb
rails_compatibility-0.0.9 lib/rails_compatibility/attribute_types.rb
rails_compatibility-0.0.8 lib/rails_compatibility/attribute_types.rb
rails_compatibility-0.0.7 lib/rails_compatibility/attribute_types.rb
rails_compatibility-0.0.6 lib/rails_compatibility/attribute_types.rb
rails_compatibility-0.0.4 lib/rails_compatibility/attribute_types.rb
rails_compatibility-0.0.3 lib/rails_compatibility/attribute_types.rb