module PIM::Services::KeyValueMapService

Public Instance Methods

__key_value_map_service() click to toggle source
# File services.rb, line 3663
def __key_value_map_service
  __service(:keyValueMapService)
end
create(map_name, key, value, &block) click to toggle source

Create a value: Only create key-value entry, when it does not exist yet Returns ‘true’ on success, ‘false’ otherwise’ Calls optional block when value already exists for key

# File services.rb, line 3634
def create map_name, key, value, &block
  success = __key_value_map_service.create_value(map_name, key, value)
  if not success and not block.nil?
    current_value = get(map_name, key)
    return block.call(current_value)
  end
  return success
end
delete(map_name, key) click to toggle source

Delete an entry

# File services.rb, line 3644
def delete map_name, key
  old_value = __key_value_map_service.delete_value(map_name, key)
end
delete_all(map_name) click to toggle source

Delete all entries for a map

# File services.rb, line 3654
def delete_all map_name
  __key_value_map_service.deleteAll(map_name)
end
get(map_name, key) click to toggle source

Retrieve the current value for a key

# File services.rb, line 3607
def get map_name, key
  value = __key_value_map_service.get_value(map_name, key)
end
get_all(map_name) click to toggle source

Get all entries for a map

# File services.rb, line 3649
def get_all map_name
  all_values = __key_value_map_service.getAll(map_name)
end
put(map_name, key, value = nil, &block) click to toggle source

Put a new value into a map, possibly updating a previous value Either specify the value to set, or provide a &block with two parameters:

- old_value: The value currently assigned to the key
- exists: true, if a value is assigned to the key and false if not

The block’s result will be assigned to the key, creating it if necessary

# File services.rb, line 3617
def put map_name, key, value = nil, &block
  old_value = if block
    __key_value_map_service.put_value(map_name, key, &block)
  else
    __key_value_map_service.put_value(map_name, key, value)
  end
end
update(map_name, key, value, create = false) click to toggle source

Updates a value in a key-value map, if it exists If ‘create’ is set to true, the entry will be created if necessary

# File services.rb, line 3627
def update map_name, key, value, create = false
  old_value = __key_value_map_service.update_value(map_name, key, value, create)
end