Class: RailsAdmin::Adapters::Mongoid::Property
- Inherits:
-
Object
- Object
- RailsAdmin::Adapters::Mongoid::Property
- Defined in:
- lib/rails_admin/adapters/mongoid.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.
213 214 215 216 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 213 def initialize(property, model) @property = property @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
211 212 213 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 211 def model @model end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
211 212 213 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 211 def property @property end |
Instance Method Details
#association? ⇒ Boolean
267 268 269 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 267 def association? false end |
#length ⇒ Object
255 256 257 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 255 def length (length_validation_lookup || 255) if type == :string end |
#name ⇒ Object
218 219 220 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 218 def name property.name.to_sym end |
#nullable? ⇒ Boolean
259 260 261 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 259 def nullable? true end |
#pretty_name ⇒ Object
222 223 224 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 222 def pretty_name property.name.to_s.tr('_', ' ').capitalize end |
#read_only? ⇒ Boolean
271 272 273 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 271 def read_only? false end |
#serial? ⇒ Boolean
263 264 265 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 263 def serial? name == :_id end |
#type ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/rails_admin/adapters/mongoid.rb', line 226 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 |