module CampingFlash

# stackoverflow.com/questions/1766741/comparing-ruby-hashes class Hash

def diff(other)
  self.keys.inject({}) do |memo, key|
    unless self[key] == other[key]
      memo[key] = [self[key], other[key]] 
    end
    memo
  end
end

Public Class Methods

included(base) click to toggle source
# File lib/tarpaulin/camping/flash.rb, line 25
  def self.included(base)
    # self is CampingFlash
    # base is TheApp
    Camping::H.class_eval <<-EOT
      def diff(other)
        self.keys.inject({}) do |memo, key|
          unless self[key] == other[key]
            memo[key] = [self[key], other[key]] 
          end
          memo
        end
      end
    EOT
  end