Sha256: 1e7263facf48a510968dce46594ea9777271cbadad8bfeed7a8ef02fccceeb4b

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

module ActiveGit
  class SynchronizationError < StandardError

    def initialize(models)
      @models = models
    end

    def message
      messages = []
      @models.each do |model|
        model.errors.full_messages.each do |msg|
          attributes = {}
          model.attributes.each do |name, value|
            attributes[model.class.human_attribute_name(name)] = value
          end

          attributes = model.attributes.inject({}) do |memo, item|
            memo[model.class.human_attribute_name(item[0])] = item[1]
            memo
          end

          messages << "#{model.class.model_name.human} - #{msg}\n#{attributes}"
        end
      end
      messages.join("\n")
    end

    def to_s
      "#{self.class.name} (#{message}):\n#{backtrace.join("\n")}"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_git-0.0.3 lib/active_git/synchronization_error.rb
active_git-0.0.2 lib/active_git/synchronization_error.rb
active_git-0.0.1 lib/active_git/synchronization_error.rb