Sha256: 5fb13f28d1ff156525de4211672822a67140e53109289228b82da97b0de12fd6

Contents?: true

Size: 749 Bytes

Versions: 2

Compression:

Stored size: 749 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.present?

      msg
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
synchronisable-1.1.2 lib/synchronisable/context.rb
synchronisable-1.1.1 lib/synchronisable/context.rb