Sha256: bce913efa66d619c9cd3fe3ff9ca1cfccb62699339133493110e0f2d77be9934

Contents?: true

Size: 651 Bytes

Versions: 35

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

35 entries across 35 versions & 1 rubygems

Version Path
auther-15.0.2 app/presenters/auther/account.rb
auther-15.0.1 app/presenters/auther/account.rb
auther-15.0.0 app/presenters/auther/account.rb
auther-14.0.3 app/presenters/auther/account.rb
auther-14.0.2 app/presenters/auther/account.rb
auther-14.0.1 app/presenters/auther/account.rb
auther-14.0.0 app/presenters/auther/account.rb
auther-13.6.0 app/presenters/auther/account.rb
auther-13.5.0 app/presenters/auther/account.rb
auther-13.4.0 app/presenters/auther/account.rb
auther-13.3.0 app/presenters/auther/account.rb
auther-13.2.3 app/presenters/auther/account.rb
auther-13.2.2 app/presenters/auther/account.rb
auther-13.2.1 app/presenters/auther/account.rb
auther-13.2.0 app/presenters/auther/account.rb
auther-13.1.0 app/presenters/auther/account.rb
auther-13.0.0 app/presenters/auther/account.rb
auther-12.2.0 app/presenters/auther/account.rb
auther-12.1.0 app/presenters/auther/account.rb
auther-12.0.3 app/presenters/auther/account.rb