Sha256: 83b064a3e4f0be66399c6354d974b6fc21a2ad82490776ee54d5b0eea25beee3

Contents?: true

Size: 732 Bytes

Versions: 1

Compression:

Stored size: 732 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
  #
  # See details in <tt>ActiveMerge::Service#provide</tt> documentation.
  #
  def merge_all
    ActiveMerge::Service.new(all).provide
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_merge-1.0.5 lib/active_merge.rb