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.1'
Instance Method Summary collapse
-
#field_name(meta) ⇒ Object
Proxies to the class level version.
-
#has_many_count(name) ⇒ Object
Counts unique children of object Needed because the mongoid callbacks dont update has_many relations until after invoked.
-
#siblings(field = :position) ⇒ Array
Retrieves an object’s list siblings.
Instance Method Details
#field_name(meta) ⇒ Object
Proxies to the class level version
37 38 39 |
# File 'lib/mongoid/listable.rb', line 37 def field_name self.class.field_name end |
#has_many_count(name) ⇒ Object
Counts unique children of object Needed because the mongoid callbacks dont update has_many relations until after invoked.
48 49 50 |
# File 'lib/mongoid/listable.rb', line 48 def has_many_count name send(name).uniq(&:id).count end |
#siblings(field = :position) ⇒ Array
Retrieves an object’s list siblings
57 58 59 60 |
# File 'lib/mongoid/listable.rb', line 57 def siblings field=:position klass = ? _parent.send(.key) : self.class klass.exists(field => true).ne id: id end |