Sha256: 343d7d6332c72a69485e4d9ade556efebc6c791c02232b0e74d72cc6d779392b

Contents?: true

Size: 516 Bytes

Versions: 1

Compression:

Stored size: 516 Bytes

Contents

module BanksApi
  class UserAccount
    def initialize(bank_name, credentials)
      @bank_name = bank_name
      @credentials = credentials
    end

    def accounts
      @accounts ||= api.fetch_accounts
    end

    def account(id)
      accounts.find do |account|
        account.id == id
      end
    end

    private

      attr_reader :bank_name, :credentials

      def api
        @_api ||= api_class.new(credentials)
      end

      def api_class
        Bank.get_bank_api(bank_name)
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
banks_api-0.1.5 lib/banks_api/user_account.rb