Sha256: 471ff1e4fbdee5508495ab2fc572eb3c9c5ebe238e079faa9ac158be8586b0c6

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

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 model.serialized_attributes[property.name.to_s]
            :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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_admin-0.6.6 lib/rails_admin/adapters/active_record/property.rb
rails_admin-0.6.5 lib/rails_admin/adapters/active_record/property.rb
rails_admin-0.6.4 lib/rails_admin/adapters/active_record/property.rb