||=
memoizes the value -- it sets the value only once -- only if it's not previously defined. When called subsequently, the value is already set and will not be modified. It uses Ruby's lazy loading to evaluate if the left-hand side as a boolean value, and only does the assignment if it is nil or false.
These two lines are equivalent:
var ||= something
var = something if var.nil? # this is equivalent to ||=
# Note: memoizing with ||= only works if the right-hand side is not a boolean function;
# because if it's value would be false, it could not use Ruby's lazy-loading
This is often used for memoizing (caching) if the right-hand-side is an expensive / time-consuming operation, or in general during initializations which have to be done only once.
Why ||= when assigning to a Constant?
Constants should only initialized once, and will at least issue a warning when you try to override them.
The ||= makes sure the value is assigned only once to the constant. This way you don't get a warning that the constant is already initialized.