class Fastly::Dictionary
Attributes
id[RW]
name[RW]
service_id[RW]
Public Class Methods
pluralize()
click to toggle source
# File lib/fastly/dictionary.rb, line 37 def self.pluralize 'dictionaries' end
Public Instance Methods
add_item(key, value)
click to toggle source
# File lib/fastly/dictionary.rb, line 18 def add_item(key, value) fetcher.create_dictionary_item(service_id: service_id, dictionary_id: id, item_key: key, item_value: value) end
delete_item(key)
click to toggle source
# File lib/fastly/dictionary.rb, line 32 def delete_item(key) di = items.select {|item| item.item_key.eql? key }.first fetcher.delete_dictionary_item(di) if di end
item(key)
click to toggle source
Returns a Fastly::DictionaryItem
corresponding to this dictionary and the key
-
key
- Key of the dictionary item
# File lib/fastly/dictionary.rb, line 12 def item(key) fetcher.get_dictionary_item(service_id, id, key) rescue Fastly::Error => e raise unless e.message =~ /Record not found/ end
items()
click to toggle source
# File lib/fastly/dictionary.rb, line 5 def items fetcher.list_dictionary_items(:service_id => service_id, :dictionary_id => id) end
update_item(key, value)
click to toggle source
# File lib/fastly/dictionary.rb, line 22 def update_item(key, value) di = items.select {|item| item.item_key.eql? key }.first if di di.item_value = value fetcher.update_dictionary_item(di) else add_item(key, value) end end