Sha256: 08b6856f1df11914b5edb554fce02cb8643b7326617fe81b91d315b0e0679581

Contents?: true

Size: 655 Bytes

Versions: 27

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

require "active_model"

module Auther
  ACCOUNT_ATTRIBUTES = %i[
    name
    encrypted_login
    encrypted_password
    paths
    authorized_url
    deauthorized_url
  ].freeze

  # Represents an authenticatable account.
  Account = Struct.new(*ACCOUNT_ATTRIBUTES, 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

27 entries across 27 versions & 1 rubygems

Version Path
auther-13.6.0 app/models/auther/account.rb
auther-13.5.0 app/models/auther/account.rb
auther-13.4.0 app/models/auther/account.rb
auther-13.3.0 app/models/auther/account.rb
auther-13.2.3 app/models/auther/account.rb
auther-13.2.2 app/models/auther/account.rb
auther-13.2.1 app/models/auther/account.rb
auther-13.2.0 app/models/auther/account.rb
auther-13.1.0 app/models/auther/account.rb
auther-13.0.0 app/models/auther/account.rb
auther-12.2.0 app/models/auther/account.rb
auther-12.1.0 app/models/auther/account.rb
auther-12.0.3 app/models/auther/account.rb
auther-12.0.2 app/models/auther/account.rb
auther-12.0.1 app/models/auther/account.rb
auther-12.0.0 app/models/auther/account.rb
auther-11.5.0 app/models/auther/account.rb
auther-11.4.0 app/models/auther/account.rb
auther-11.3.0 app/models/auther/account.rb
auther-11.2.0 app/models/auther/account.rb