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.



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

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

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/rails_admin/adapters/active_record/property.rb', line 5

def model
  @model
end

#propertyObject (readonly)

Returns the value of attribute property.



5
6
7
# File 'lib/rails_admin/adapters/active_record/property.rb', line 5

def property
  @property
end

Instance Method Details

#association?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rails_admin/adapters/active_record/property.rb', line 40

def association?
  false
end

#lengthObject



28
29
30
# File 'lib/rails_admin/adapters/active_record/property.rb', line 28

def length
  property.limit
end

#nameObject



12
13
14
# File 'lib/rails_admin/adapters/active_record/property.rb', line 12

def name
  property.name.to_sym
end

#nullable?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/rails_admin/adapters/active_record/property.rb', line 32

def nullable?
  property.null
end

#pretty_nameObject



16
17
18
# File 'lib/rails_admin/adapters/active_record/property.rb', line 16

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

#read_only?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/rails_admin/adapters/active_record/property.rb', line 44

def read_only?
  false
end

#serial?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/rails_admin/adapters/active_record/property.rb', line 36

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

#typeObject



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

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