123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Threaded::Lifecycle

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/threaded/lifecycle.rb

Overview

This module contains convenience methods for document lifecycle that resides on thread locals.

Instance Attribute Summary

Instance Attribute Details

#_assigningObject (readonly, private)

Begin the assignment of attributes. While in this block embedded documents will not autosave themselves in order to allow the document to be in a valid state.

Examples:

Execute the assignment.

_assigning do
  person.attributes = { :addresses => [ address ] }
end

Returns:

  • (Object)

    The yielded value.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 29

def _assigning
  Threaded.begin_execution(ASSIGN)
  yield
ensure
  Threaded.exit_execution(ASSIGN)
end

#_assigning?true | false (readonly, private)

Is the current thread in assigning mode?

Examples:

Is the current thread in assigning mode?

proxy._assigning?

Returns:

  • (true | false)

    If the thread is assigning.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 42

def _assigning?
  Threaded.executing?(ASSIGN)
end

#_bindingObject (readonly, private)

Execute a block in binding mode.

Examples:

Execute in binding mode.

binding do
  relation.push(doc)
end

Returns:

  • (Object)

    The return value of the block.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 54

def _binding
  Threaded.begin_execution(BIND)
  yield
ensure
  Threaded.exit_execution(BIND)
end

#_binding?true | false (readonly, private)

Is the current thread in binding mode?

Examples:

Is the current thread in binding mode?

proxy.binding?

Returns:

  • (true | false)

    If the thread is binding.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 67

def _binding?
  Threaded.executing?(BIND)
end

#_buildingObject (readonly, private)

Execute a block in building mode.

Examples:

Execute in building mode.

_building do
  relation.push(doc)
end

Returns:

  • (Object)

    The return value of the block.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 79

def _building
  Threaded.begin_execution(BUILD)
  yield
ensure
  Threaded.exit_execution(BUILD)
end

#_building?true | false (readonly, private)

Is the current thread in building mode?

Examples:

Is the current thread in building mode?

proxy._building?

Returns:

  • (true | false)

    If the thread is building.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 92

def _building?
  Threaded.executing?(BUILD)
end

#_creating?true | false (readonly, private)

Is the current thread in creating mode?

Examples:

Is the current thread in creating mode?

proxy.creating?

Returns:

  • (true | false)

    If the thread is creating.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 102

def _creating?
  Threaded.executing?(CREATE)
end

#_loadingObject (readonly, private)

Execute a block in loading mode.

Examples:

Execute in loading mode.

_loading do
  relation.push(doc)
end

Returns:

  • (Object)

    The return value of the block.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 114

def _loading
  Threaded.begin_execution(LOAD)
  yield
ensure
  Threaded.exit_execution(LOAD)
end

#_loading?true | false (readonly, private)

Is the current thread in loading mode?

Examples:

Is the current thread in loading mode?

proxy._loading?

Returns:

  • (true | false)

    If the thread is loading.

[ GitHub ]

  
# File 'lib/mongoid/threaded/lifecycle.rb', line 127

def _loading?
  Threaded.executing?(LOAD)
end