Sha256: 724d8edc540179315ae1367f152a08c7a05c9b213e744504a7050cc2a635113e

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

require 'digest/md5'

module Fog
  module Rackspace
    class Monitoring
      class Base < Fog::Model

        attribute :created_at
        attribute :updated_at

        # Back to drawing board on this one I think
        def hash
          attrs = attributes.dup
          attrs.delete_if {|key, value| [:created_at, :updated_at, :id].include?(key)}
          attrs.delete_if {|key, value| value.kind_of?(Base) }
          keys = attrs.keys.map{|sym| sym.to_s}.sort.join ''
          values = attrs.values.map{|sym| sym.to_s}.sort.join ''
          Digest::MD5.hexdigest(keys + values)
        end

        def compare?(b)
          a_o = params
          b_o = b.params
          remain = a_o.reject {|key, value| b_o[key] === value}
          remain.empty?
        end

        def entity_id
          raise(ArgumentError, "entity with id is required for this operation") unless entity && entity.identity
          entity.identity
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gapinc-fog-1.14.0 lib/fog/rackspace/models/monitoring/base.rb