Sha256: c64f5eec0a93e7bf95cbdcffca1f0f9ba10bb6a173b4b22df2b1850545a1a5b8

Contents?: true

Size: 605 Bytes

Versions: 12

Compression:

Stored size: 605 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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
auther-17.0.0 app/models/auther/account.rb
auther-16.10.0 app/models/auther/account.rb
auther-16.9.0 app/models/auther/account.rb
auther-16.8.0 app/models/auther/account.rb
auther-16.7.0 app/models/auther/account.rb
auther-16.6.0 app/models/auther/account.rb
auther-16.5.0 app/models/auther/account.rb
auther-16.4.0 app/models/auther/account.rb
auther-16.3.0 app/models/auther/account.rb
auther-16.2.0 app/models/auther/account.rb
auther-16.1.0 app/models/auther/account.rb
auther-16.0.0 app/models/auther/account.rb