123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Scopable

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveSupport::Concern
Defined in: lib/mongoid/scopable.rb

Overview

This module contains behavior for all ::Mongoid scoping - named scopes, default scopes, and criteria accessors via scoped and unscoped.

Instance Method Summary

DSL Calls

included

[ GitHub ]


9
10
11
12
13
# File 'lib/mongoid/scopable.rb', line 9

included do
  class_attribute :default_scoping
  class_attribute :_declared_scopes
  self._declared_scopes = {}
end

Instance Method Details

#apply_default_scopingtrue | false (private)

This method is for internal use only.

Apply the default scoping to the attributes of the document, as long as they are not complex queries.

Examples:

Apply the default scoping.

document.apply_default_scoping

Returns:

  • (true | false)

    If default scoping was applied.

[ GitHub ]

  
# File 'lib/mongoid/scopable.rb', line 26

def apply_default_scoping
  return unless default_scoping

  default_scoping.call.selector.each do |field, value|
    attributes[field] = value unless value.respond_to?(:each)
  end
end