Sha256: 38927f68f6b8953da89c8075d806fd926cb4461d1059b9b81e2bc81f1cdc3385

Contents?: true

Size: 615 Bytes

Versions: 7

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

require "active_model"

module Auther
  # Represents an authenticatable account.
  Account = Struct.new(
    :name,
    :encrypted_login,
    :encrypted_password,
    :paths,
    :authorized_url,
    :deauthorized_url,
    keyword_init: true
  ) do
    include ActiveModel::Validations

    validates :name, :encrypted_login, :encrypted_password, presence: true
    validate :paths_type

    def initialize *arguments
      super
      self[:paths] ||= []
    end

    private

    def paths_type
      errors.add :paths, "must be an array" unless paths.is_a? Array
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
auther-15.0.2 app/models/auther/account.rb
auther-15.0.1 app/models/auther/account.rb
auther-15.0.0 app/models/auther/account.rb
auther-14.0.3 app/models/auther/account.rb
auther-14.0.2 app/models/auther/account.rb
auther-14.0.1 app/models/auther/account.rb
auther-14.0.0 app/models/auther/account.rb