Sha256: fee1d98b681c02baf6dda0caa596ec0e937aeb24d3b812f3fd80c5f190ecc04e

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require "active_model"

module Auther
  # Represents an authenticatable account.
  class Account
    include ActiveModel::Validations

    attr_accessor :name,
                  :encrypted_login,
                  :encrypted_password,
                  :paths,
                  :authorized_url,
                  :deauthorized_url

    validates :name, :encrypted_login, :encrypted_password, presence: true
    validates :paths, presence: {
      unless: ->(account) { account.paths.is_a? Array },
      message: "must be an array"
    }

    # rubocop:disable Style/OptionHash
    def initialize options = {}
      @name = options.fetch :name, nil
      @encrypted_login = options.fetch :encrypted_login, nil
      @encrypted_password = options.fetch :encrypted_password, nil
      @paths = options.fetch :paths, []
      @authorized_url = options.fetch :authorized_url, nil
      @deauthorized_url = options.fetch :deauthorized_url, nil
    end
    # rubocop:enable Style/OptionHash
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
auther-9.1.0 app/models/auther/account.rb
auther-9.0.0 app/models/auther/account.rb