class Plangrade::Resources::IdentityMap

Public Class Methods

new() click to toggle source
# File lib/plangrade/resources/identity_map.rb, line 7
def initialize
  @map  = {}
  @size = 0
end

Public Instance Methods

get(key, default=nil) click to toggle source

@note retrives key from identity map @return [Hash] @param key [string] @param default [Hash]

# File lib/plangrade/resources/identity_map.rb, line 16
def get(key, default=nil)
  @map["#{key}"] || default
end
purge!() click to toggle source

clears the entire identity map @return [Hash]

# File lib/plangrade/resources/identity_map.rb, line 39
def purge!
  @map = {}
end
put(key, value) click to toggle source

@note inserts a hash of attributes into identity map @return [Hash] @param key [string] @param value [Hash]

# File lib/plangrade/resources/identity_map.rb, line 24
def put(key, value)
  if key.nil? || key.empty?
    raise InvalidKeyError.new
  end
  @map["#{key}"] = value
end
size() click to toggle source

@note returns the current size of identity map @return [Integer]

# File lib/plangrade/resources/identity_map.rb, line 33
def size
  @map.keys.count
end