Class: RailsAdmin::Adapters::Mongoid::Property
- Inherits:
-
Object
- Object
- RailsAdmin::Adapters::Mongoid::Property
- Defined in:
- lib/rails_admin/adapters/mongoid/property.rb
Constant Summary collapse
- STRING_TYPE_COLUMN_NAMES =
%i[name title subject].freeze
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.
10 11 12 13 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 10 def initialize(property, model) @property = property @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 8 def model @model end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
8 9 10 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 8 def property @property end |
Instance Method Details
#association? ⇒ Boolean
64 65 66 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 64 def association? false end |
#length ⇒ Object
52 53 54 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 52 def length (length_validation_lookup || 255) if type == :string end |
#name ⇒ Object
15 16 17 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 15 def name (property.[:as] || property.name).to_sym end |
#nullable? ⇒ Boolean
56 57 58 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 56 def nullable? true end |
#pretty_name ⇒ Object
19 20 21 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 19 def pretty_name (property.[:as] || property.name).to_s.tr('_', ' ').capitalize end |
#read_only? ⇒ Boolean
68 69 70 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 68 def read_only? model.readonly_attributes.include? property.name.to_s end |
#serial? ⇒ Boolean
60 61 62 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 60 def serial? name == :_id end |
#type ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rails_admin/adapters/mongoid/property.rb', line 23 def type case property.type.to_s when 'Array', 'Hash', 'Money' :serialized when 'BigDecimal' :decimal when 'Boolean', 'Mongoid::Boolean' :boolean when 'BSON::ObjectId', 'Moped::BSON::ObjectId' :bson_object_id when 'Date' :date when 'ActiveSupport::TimeWithZone', 'DateTime', 'Time' :datetime when 'Float' :float when 'Integer' :integer when 'Object' object_field_type when 'String' string_field_type when 'Symbol' :string else :string end end |