lib/health-data-standards/models/entry.rb in health-data-standards-0.5.0 vs lib/health-data-standards/models/entry.rb in health-data-standards-0.7.0

- old
+ new

@@ -148,9 +148,26 @@ # @return [true, false] def usable? codes.present? && (start_time.present? || end_time.present? || time.present?) end + # Compares hash values to determine equality + def ==(other) + self.class==other.class && self.hash==other.hash + end + + # Returns the hash value, calculating it if not already done + def hash + @hash || calculate_hash! + end + + # Calculates a hash value for this entry + def calculate_hash! + entry_hash = to_hash + entry_hash['description']=nil + @hash = entry_hash.hash + end + # Creates a Hash for this Entry # @return [Hash] a Hash representing the Entry def to_hash entry_hash = {} entry_hash['codes'] = codes \ No newline at end of file