Sha256: 8e4c5480554f85984138ee8b24582cc3ab5cc2f7ad7a902b7c0358acd41a7273

Contents?: true

Size: 1.08 KB

Versions: 15

Compression:

Stored size: 1.08 KB

Contents

module RailsAdmin
  module Adapters
    module ActiveRecord
      class Property
        attr_reader :property, :model

        def initialize(property, model)
          @property = property
          @model = model
        end

        def name
          property.name.to_sym
        end

        def pretty_name
          property.name.to_s.tr('_', ' ').capitalize
        end

        def type
          if serialized?
            :serialized
          else
            property.type
          end
        end

        def length
          property.limit
        end

        def nullable?
          property.null
        end

        def serial?
          model.primary_key == property.name
        end

        def association?
          false
        end

        def read_only?
          false
        end

      private

        def serialized?
          if Rails.version < '4.2'
            model.serialized_attributes[property.name.to_s]
          else
            model.type_for_attribute(property.name).class == ::ActiveRecord::Type::Serialized
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
rails_admin-1.4.3 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.4.2 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.4.1 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.4.0 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.3.0 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.2.0 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.1.1 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.1.0 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.0.0 lib/rails_admin/adapters/active_record/property.rb
rails_admin-1.0.0.rc lib/rails_admin/adapters/active_record/property.rb
rails_admin-0.8.1 lib/rails_admin/adapters/active_record/property.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rails_admin-0.7.0/lib/rails_admin/adapters/active_record/property.rb
rails_admin-0.7.0 lib/rails_admin/adapters/active_record/property.rb
rails_admin-0.6.8 lib/rails_admin/adapters/active_record/property.rb
rails_admin-0.6.7 lib/rails_admin/adapters/active_record/property.rb