Module: Mongoid::Listable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid/listable.rb,
lib/mongoid/listable/macros.rb,
lib/mongoid/listable/version.rb,
lib/mongoid/listable/accessors.rb,
lib/mongoid/listable/callbacks.rb,
lib/mongoid/listable/extensions/array.rb,
lib/mongoid/listable/extensions/object.rb
Defined Under Namespace
Modules: Accessors, Callbacks, ClassMethods, Extensions, Macros
Constant Summary collapse
- VERSION =
'0.2.3'
Instance Method Summary collapse
-
#many(name) ⇒ Object
Finds unique instances of objects for a given relation Needed because the mongoid callbacks dont update has_many relations until after invoked.
-
#position_field_name(meta) ⇒ Object
Proxies to the class level determine_position_field_name.
-
#siblings(field = :position) ⇒ Array
Retrieves siblings of an object in a list.
Instance Method Details
#many(name) ⇒ Object
Finds unique instances of objects for a given relation Needed because the mongoid callbacks dont update has_many relations until after invoked.
33 34 35 |
# File 'lib/mongoid/listable.rb', line 33 def many name send(name).uniq(&:id) end |
#position_field_name(meta) ⇒ Object
Proxies to the class level determine_position_field_name
22 23 24 |
# File 'lib/mongoid/listable.rb', line 22 def position_field_name self.class.determine_position_field_name end |
#siblings(field = :position) ⇒ Array
Retrieves siblings of an object in a list. Scoped by the position fiels name
43 44 45 46 |
# File 'lib/mongoid/listable.rb', line 43 def siblings field=:position klass = ? _parent.send(.key) : self.class klass.exists(field => true).ne id: id end |