Module: Mongoid::History::Trackable::RelationMethods
- Defined in:
- lib/mongoid/history/trackable.rb
Instance Method Summary collapse
-
#embeds_many?(field) ⇒ Boolean
Indicates whether there is an Embedded::Many relation for the given embedded field.
-
#embeds_one?(field) ⇒ Boolean
Indicates whether there is an Embedded::One relation for the given embedded field.
-
#relation_alias(embed) ⇒ String
Retrieves the database representation of an embedded field name, in case the :store_as option is used.
-
#relation_class_of(field) ⇒ nil | Constant
Returns a relation class for the given field.
Instance Method Details
#embeds_many?(field) ⇒ Boolean
Indicates whether there is an Embedded::Many relation for the given embedded field.
384 385 386 387 388 389 390 |
# File 'lib/mongoid/history/trackable.rb', line 384 def (field) relation_of(field) == if Mongoid::Compatibility::Version.mongoid7_or_newer? Mongoid::Association::Embedded::EmbedsMany::Proxy else Mongoid::Relations::Embedded::Many end end |
#embeds_one?(field) ⇒ Boolean
Indicates whether there is an Embedded::One relation for the given embedded field.
371 372 373 374 375 376 377 |
# File 'lib/mongoid/history/trackable.rb', line 371 def (field) relation_of(field) == if Mongoid::Compatibility::Version.mongoid7_or_newer? Mongoid::Association::Embedded::EmbedsOne::Proxy else Mongoid::Relations::Embedded::One end end |
#relation_alias(embed) ⇒ String
Retrieves the database representation of an embedded field name, in case the :store_as option is used.
397 398 399 |
# File 'lib/mongoid/history/trackable.rb', line 397 def relation_alias() relation_aliases[] end |
#relation_class_of(field) ⇒ nil | Constant
Returns a relation class for the given field.
361 362 363 364 |
# File 'lib/mongoid/history/trackable.rb', line 361 def relation_class_of(field) = (field) return .class_name.constantize if end |