Class: Keen::ScopedKey
- Inherits:
-
Object
- Object
- Keen::ScopedKey
- Defined in:
- lib/keen/scoped_key.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #encrypt!(iv = nil) ⇒ Object
-
#initialize(api_key, data) ⇒ ScopedKey
constructor
A new instance of ScopedKey.
Constructor Details
#initialize(api_key, data) ⇒ ScopedKey
Returns a new instance of ScopedKey.
23 24 25 26 |
# File 'lib/keen/scoped_key.rb', line 23 def initialize(api_key, data) self.api_key = api_key self.data = data end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/keen/scoped_key.rb', line 8 def api_key @api_key end |
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/keen/scoped_key.rb', line 9 def data @data end |
Class Method Details
.decrypt!(api_key, scoped_key) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/keen/scoped_key.rb', line 12 def decrypt!(api_key, scoped_key) if api_key.length == 64 decrypted = Keen::AESHelper.aes256_decrypt(api_key, scoped_key) else decrypted = Keen::AESHelperOld.aes256_decrypt(api_key, scoped_key) end data = MultiJson.load(decrypted) self.new(api_key, data) end |
Instance Method Details
#encrypt!(iv = nil) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/keen/scoped_key.rb', line 28 def encrypt!(iv = nil) json_str = MultiJson.dump(self.data) if self.api_key.length == 64 Keen::AESHelper.aes256_encrypt(self.api_key, json_str, iv) else Keen::AESHelperOld.aes256_encrypt(self.api_key, json_str, iv) end end |