Class: RailsAdmin::Adapters::ActiveRecord::Property
- Inherits:
-
Object
- Object
- RailsAdmin::Adapters::ActiveRecord::Property
- Defined in:
- lib/rails_admin/adapters/active_record/property.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
Instance Method Summary collapse
- #association? ⇒ Boolean
-
#initialize(property, model) ⇒ Property
constructor
A new instance of Property.
- #length ⇒ Object
- #name ⇒ Object
- #nullable? ⇒ Boolean
- #pretty_name ⇒ Object
- #read_only? ⇒ Boolean
- #serial? ⇒ Boolean
- #type ⇒ Object
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
#model ⇒ Object (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 |
#property ⇒ Object (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
42 43 44 |
# File 'lib/rails_admin/adapters/active_record/property.rb', line 42 def association? false end |
#length ⇒ Object
30 31 32 |
# File 'lib/rails_admin/adapters/active_record/property.rb', line 30 def length property.limit end |
#name ⇒ Object
14 15 16 |
# File 'lib/rails_admin/adapters/active_record/property.rb', line 14 def name property.name.to_sym end |
#nullable? ⇒ Boolean
34 35 36 |
# File 'lib/rails_admin/adapters/active_record/property.rb', line 34 def nullable? property.null end |
#pretty_name ⇒ Object
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
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
38 39 40 |
# File 'lib/rails_admin/adapters/active_record/property.rb', line 38 def serial? model.primary_key == property.name end |
#type ⇒ Object
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 |