Sha256: 35f1e15b1724b3961fd94e36aff36238bfe145a4bab6ee8b14e35de8caa60f61

Contents?: true

Size: 715 Bytes

Versions: 5

Compression:

Stored size: 715 Bytes

Contents

module Synchronisable
  # Synchronization context.
  class Context
    attr_accessor :model, :errors,
                  :before, :after, :deleted

    def initialize(model, parent)
      @model, @parent = model, parent
      @errors = []
      @before, @after, @deleted = 0, 0, 0
    end

    # @return [String] summary synchronization info
    def summary_message
      msg = I18n.t('messages.result',
        :model   => model,
        :parent  => @parent.try(:model) || 'nil',
        :before  => before,
        :after   => after,
        :deleted => deleted,
        :errors  => errors.count
      )

      msg << I18n.t('messages.errors', errors: errors.join('. ')) if errors.any?
      msg
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
synchronisable-1.2.6 lib/synchronisable/context.rb
synchronisable-1.2.5 lib/synchronisable/context.rb
synchronisable-1.2.4 lib/synchronisable/context.rb
synchronisable-1.2.3 lib/synchronisable/context.rb
synchronisable-1.2.2 lib/synchronisable/context.rb