Sha256: 438dc4118cca5e52edf68930dad1ca855419e9c21454238cba928b26c737e629

Contents?: true

Size: 651 Bytes

Versions: 8

Compression:

Stored size: 651 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
      end

      def error_message key
        return "" unless error?(key)
        "#{key.capitalize} #{errors.messages[key].first}"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
auther-9.3.0 app/presenters/auther/account.rb
auther-9.2.0 app/presenters/auther/account.rb
auther-9.1.0 app/presenters/auther/account.rb
auther-9.0.0 app/presenters/auther/account.rb
auther-8.1.1 app/presenters/auther/account.rb
auther-8.1.0 app/presenters/auther/account.rb
auther-8.0.0 app/presenters/auther/account.rb
auther-7.1.0 app/presenters/auther/account.rb