Class: RailsAdmin::Adapters::ActiveRecord::Property

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property, model) ⇒ Property

Returns a new instance of Property.



143
144
145
146
# File 'lib/rails_admin/adapters/active_record.rb', line 143

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

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



141
142
143
# File 'lib/rails_admin/adapters/active_record.rb', line 141

def model
  @model
end

#propertyObject (readonly)

Returns the value of attribute property.



141
142
143
# File 'lib/rails_admin/adapters/active_record.rb', line 141

def property
  @property
end

Instance Method Details

#association?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/rails_admin/adapters/active_record.rb', line 176

def association?
  false
end

#lengthObject



164
165
166
# File 'lib/rails_admin/adapters/active_record.rb', line 164

def length
  property.limit
end

#nameObject



148
149
150
# File 'lib/rails_admin/adapters/active_record.rb', line 148

def name
  property.name.to_sym
end

#nullable?Boolean

Returns:

  • (Boolean)


168
169
170
# File 'lib/rails_admin/adapters/active_record.rb', line 168

def nullable?
  property.null
end

#pretty_nameObject



152
153
154
# File 'lib/rails_admin/adapters/active_record.rb', line 152

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

#read_only?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/rails_admin/adapters/active_record.rb', line 180

def read_only?
  false
end

#serial?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'lib/rails_admin/adapters/active_record.rb', line 172

def serial?
  property.primary
end

#typeObject



156
157
158
159
160
161
162
# File 'lib/rails_admin/adapters/active_record.rb', line 156

def type
  if model.serialized_attributes[property.name.to_s]
    :serialized
  else
    property.type
  end
end