Sha256: e834b4393fca9390fcc332d079b40d51c1a2d5d9ff98cab35a4d15c8047b2d68

Contents?: true

Size: 636 Bytes

Versions: 12

Compression:

Stored size: 636 Bytes

Contents

# frozen_string_literal: true

require "active_model"

module Auther
  module Presenter
    # Adapter for presenting an account within a view.
    class Account
      include ActiveModel::Validations

      attr_accessor :name, :login, :password

      validates :name, :login, :password, presence: true

      def initialize name: "", login: "", password: ""
        @name = name
        @login = login
        @password = password
      end

      def error?(key) = errors.key? key

      def error_message key
        return "" unless error? key

        "#{key.capitalize} #{errors.messages[key].first}"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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