Sha256: 0a352f87bf69b41b1316584342c4067e9a4b37a8a7071cd58f31820017012390

Contents?: true

Size: 942 Bytes

Versions: 3

Compression:

Stored size: 942 Bytes

Contents

require "active_patterns"

# Declares service object for merging ActiveRecord instances.
#
# After extending your active record model with the module,
# new <tt>::merge_all</tt> method is available.
#
module ActiveMerge
  extend ActiveSupport::Autoload

  autoload :SimpleService
  autoload :Service

  # Merges instances from the association
  #
  #     class Lord < ActiveRecord::Base
  #       extend ActiveMerge
  #     end
  #
  #     Lord.all.merge_all              # => merges all the class instances
  #     Lord.where("id > :id", id: 100) # => merges instances with id > 100
  #
  # You can use the <tt>validate: false</tt> option.
  #
  # With this option set any activerecord validation and callback are skipped.
  #
  #     Post.all.merge_all validate: false
  #
  # See details in <tt>ActiveMerge::Service#provide</tt> documentation.
  #
  def merge_all(options = {})
    ActiveMerge::Service.new(all).provide(options)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_merge-1.2.1 lib/active_merge.rb
active_merge-1.2.0 lib/active_merge.rb
active_merge-1.1.0 lib/active_merge.rb