Sha256: 2e5bc677b0996f0371874336e9af7ddfcf5eba57727cb452518ee953c4dd5190

Contents?: true

Size: 836 Bytes

Versions: 5

Compression:

Stored size: 836 Bytes

Contents

require 'attr_encrypted'

class Comfy::Admin::Meetalendar::AuthCredential < ApplicationRecord
  self.table_name = "meetalendar_auth_credentials"

  # TODO(Schau): There might be a better place for this function
  def self.expand_env(str)
    str.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/) { ENV[$1] }
  end

  attr_encrypted :access_token, key: Rails.application.secrets.secret_key_base.to_s.bytes[0..31].pack("c" * 32)
  attr_encrypted :refresh_token, key: Rails.application.secrets.secret_key_base.to_s.bytes[0..31].pack("c" * 32)

  def scope
    # NOTE(Schau): Scope expected to be a json parsable string that results in an array.
    parsed_scope = JSON.parse(self.scope_json)
    parsed_scope = parsed_scope.empty? ? [] : parsed_scope
  end
  def scope=(new_scope)
    self.scope_json = new_scope.to_json.to_s
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
meetalendar-0.1.0 app/models/comfy/admin/meetalendar/auth_credential.rb
meetalendar-0.0.4 app/models/comfy/admin/meetalendar/auth_credential.rb
meetalendar-0.0.3 app/models/comfy/admin/meetalendar/auth_credential.rb
meetalendar-0.0.2 app/models/comfy/admin/meetalendar/auth_credential.rb
meetalendar-0.0.1 app/models/comfy/admin/meetalendar/auth_credential.rb