Method: Graphcommons::API.set_key

Defined in:
lib/graphcommons.rb

.set_key(key) ⇒ Object

Sets API key.

Returns true if key is changed, false if not changed, raises APIError if key argument fails /^sk_.22$/ test.

To get the key, please visit graphcommons.com/me/edit



89
90
91
92
93
94
95
96
97
# File 'lib/graphcommons.rb', line 89

def self.set_key key
  raise Graphcommons::APIError.new("Invalid API key\nKey should be in following format: sk_XXXXXXXXXXXXXXXXXXXXXX") unless key.match(/^sk_.{22}$/)
  if @@apikey == key
    return false
  else
    @@apikey = key
    true
  end
end