Sha256: 78ba96b015c9cef4ff93008928f4203708f41354835c24e13992a22b0195ed26

Contents?: true

Size: 989 Bytes

Versions: 4

Compression:

Stored size: 989 Bytes

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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
auther-8.1.1 app/models/auther/account.rb
auther-8.1.0 app/models/auther/account.rb
auther-8.0.0 app/models/auther/account.rb
auther-7.1.0 app/models/auther/account.rb