module FlatMap::OpenMapper::Skipping
This helper module provides helper functionality that allow to exclude specific mapper from a processing chain.
Public Instance Methods
Override {FlatMap::OpenMapper::Persistence#save} method to force it to return true
if self
is marked for skipping.
@return [Boolean]
# File lib/flat_map/open_mapper/skipping.rb, line 47 def save skipped? || super end
Override {FlatMap::OpenMapper::Persistence#shallow_save} method to make it possible to skip traits.
@return [Boolean]
# File lib/flat_map/open_mapper/skipping.rb, line 55 def shallow_save skipped? || super end
Mark self as skipped, i.e. it will not be subject of validation and saving chain.
@return [Object]
# File lib/flat_map/open_mapper/skipping.rb, line 13 def skip! @_skip_processing = true end
Return true
if self
was marked for skipping.
@return [Boolean]
# File lib/flat_map/open_mapper/skipping.rb, line 28 def skipped? !!@_skip_processing end
Remove “skip” mark from self
and “destroyed” flag from the target.
@return [Object]
# File lib/flat_map/open_mapper/skipping.rb, line 21 def use! @_skip_processing = nil end
Override {FlatMap::OpenMapper::Persistence#valid?} to force it to return true
if self
is marked for skipping.
@param [Symbol] context useless context parameter to make it compatible with
ActiveRecord models.
@return [Boolean]
# File lib/flat_map/open_mapper/skipping.rb, line 39 def valid?(context = nil) skipped? || super end
Mark self as used and then delegated to original {FlatMap::OpenMapper::Persistence#write}.
# File lib/flat_map/open_mapper/skipping.rb, line 61 def write(*) use! super end