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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property, model) ⇒ Property

Returns a new instance of Property.



9
10
11
12
# File 'lib/rails_admin/adapters/active_record/property.rb', line 9

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

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



7
8
9
# File 'lib/rails_admin/adapters/active_record/property.rb', line 7

def model
  @model
end

#propertyObject (readonly)

Returns the value of attribute property.



7
8
9
# File 'lib/rails_admin/adapters/active_record/property.rb', line 7

def property
  @property
end

Instance Method Details

#association?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/rails_admin/adapters/active_record/property.rb', line 42

def association?
  false
end

#lengthObject



30
31
32
# File 'lib/rails_admin/adapters/active_record/property.rb', line 30

def length
  property.limit
end

#nameObject



14
15
16
# File 'lib/rails_admin/adapters/active_record/property.rb', line 14

def name
  property.name.to_sym
end

#nullable?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/rails_admin/adapters/active_record/property.rb', line 34

def nullable?
  property.null
end

#pretty_nameObject



18
19
20
# File 'lib/rails_admin/adapters/active_record/property.rb', line 18

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

#read_only?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/rails_admin/adapters/active_record/property.rb', line 46

def read_only?
  model.readonly_attributes.include? property.name.to_s
end

#serial?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/rails_admin/adapters/active_record/property.rb', line 38

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

#typeObject



22
23
24
25
26
27
28
# File 'lib/rails_admin/adapters/active_record/property.rb', line 22

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