Class: Encryptable

Inherits:
Object
  • Object
show all
Defined in:
lib/models/encryptable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, username: nil, password: nil, ose_secret: nil, type: nil, id: nil) ⇒ Encryptable

Returns a new instance of Encryptable.



7
8
9
10
11
12
13
14
15
# File 'lib/models/encryptable.rb', line 7

def initialize(name: nil, username: nil, password: nil,
               ose_secret: nil, type: nil, id: nil)
  @id = id
  @name = name
  @username = username
  @password = password
  @ose_secret = ose_secret
  @type = type || 'credentials'
end

Instance Attribute Details

#folderObject

Returns the value of attribute folder.



5
6
7
# File 'lib/models/encryptable.rb', line 5

def folder
  @folder
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/models/encryptable.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/models/encryptable.rb', line 4

def name
  @name
end

#ose_secretObject (readonly)

Returns the value of attribute ose_secret.



4
5
6
# File 'lib/models/encryptable.rb', line 4

def ose_secret
  @ose_secret
end

#passwordObject (readonly)

Returns the value of attribute password.



4
5
6
# File 'lib/models/encryptable.rb', line 4

def password
  @password
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/models/encryptable.rb', line 4

def type
  @type
end

#usernameObject (readonly)

Returns the value of attribute username.



4
5
6
# File 'lib/models/encryptable.rb', line 4

def username
  @username
end

Class Method Details

.find(id) ⇒ Object



30
31
32
# File 'lib/models/encryptable.rb', line 30

def find(id)
  EncryptableSerializer.from_json(CryptopusAdapter.new.get("encryptables/#{id}"))
end

.find_by_name_and_folder_id(name, id) ⇒ Object



34
35
36
37
38
# File 'lib/models/encryptable.rb', line 34

def find_by_name_and_folder_id(name, id)
  Folder.find(id).encryptables.find do |encryptable|
    encryptable.name.downcase == name.downcase
  end
end

.from_json(json) ⇒ Object



40
41
42
# File 'lib/models/encryptable.rb', line 40

def from_json(json)
  EncryptableSerializer.from_json(json)
end

Instance Method Details

#to_json(*_args) ⇒ Object



17
18
19
# File 'lib/models/encryptable.rb', line 17

def to_json(*_args)
  EncryptableSerializer.to_json(self)
end

#to_osesecretObject



25
26
27
# File 'lib/models/encryptable.rb', line 25

def to_osesecret
  EncryptableSerializer.to_osesecret(self)
end

#to_yamlObject



21
22
23
# File 'lib/models/encryptable.rb', line 21

def to_yaml
  EncryptableSerializer.to_yaml(self)
end