lib/base/scope.js
function(name, fn, lazy) {
    const Utils = this.store.utils

    if (!fn && this.model) fn = this.model[name]
    if (!fn)
      throw new Error('You need to provide a function in order to use a scope')

    var tmp = function() {
      var args = Utils.args(arguments)
      const self = this.chain()._unresolve() // if the collection is already resolved, return a unresolved and empty copy!

      if (lazy) {
        self.addInternal('active_scopes', function() {
          return fn.apply(this, args)
        })
      } else {
        fn.apply(self, args)
      }

      return self
    }

    this.staticMethods[name] = tmp

    return this
  }
function(name, fn, lazy) {
    const Utils = this.store.utils

    if (!fn && this.model) fn = this.model[name]
    if (!fn)
      throw new Error('You need to provide a function in order to use a scope')

    var tmp = function() {
      var args = Utils.args(arguments)
      const self = this.chain()._unresolve() // if the collection is already resolved, return a unresolved and empty copy!

      if (lazy) {
        self.addInternal('active_scopes', function() {
          return fn.apply(this, args)
        })
      } else {
        fn.apply(self, args)
      }

      return self
    }

    this.staticMethods[name] = tmp

    return this
  }
function ( name , fn , lazy ) { const Utils = this . store . utils if ( ! fn && this . model ) fn = this . model [ name ] if ( ! fn ) throw new Error ( 'You need to provide a function in order to use a scope' ) var tmp = function ( ) { var args = Utils . args ( arguments ) const self = this . chain ( ) . _unresolve ( ) // if the collection is already resolved, return a unresolved and empty copy! if ( lazy ) { self . addInternal ( 'active_scopes' , function ( ) { return fn . apply ( this , args ) } ) } else { fn . apply ( self , args ) } return self } this . staticMethods [ name ] = tmp return this }
scope callback function

@public
@callback scopeFN
@param {*} args - All caller arguments
@return *
@this Model
 
Creates a custom chained Model method

@public
@memberof Definition
@method scope
@param {string} name - The name of the scope
@param {scopeFN} callback - The scope function
@return {Definition}
scope callback function