class AccountSerializer
Public Class Methods
from_json(json)
click to toggle source
# File lib/serializers/account_serializer.rb, line 41 def from_json(json) json = JSON.parse(json, symbolize_names: true) data = json[:data] || json attributes = data[:attributes] Account.new(accountname: attributes[:accountname], username: attributes[:cleartext_username], password: attributes[:cleartext_password], ose_secret: attributes[:ose_secret], type: attributes[:type], id: data[:id]) end
to_json(account)
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/serializers/account_serializer.rb, line 8 def to_json(account) { data: { type: 'accounts', id: account.id, attributes: { accountname: account.accountname, type: account.type, cleartext_username: account.username, cleartext_password: account.password, ose_secret: account.ose_secret }, relationships: { folder: { data: { id: account.folder, type: 'folders' } } } } }.compact.to_json end
to_osesecret(account)
click to toggle source
# File lib/serializers/account_serializer.rb, line 53 def to_osesecret(account) OSESecret.from_yaml(account.ose_secret) end
to_yaml(account)
click to toggle source
rubocop:enable Metrics/MethodLength
# File lib/serializers/account_serializer.rb, line 33 def to_yaml(account) { 'id' => account.id, 'accountname' => account.accountname, 'username' => account.username, 'password' => account.password, 'type' => account.type }.to_yaml end