From 3e2a08fb88452c78d18c0fb890e132e5c7d8cdb5 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 28 May 2025 14:02:12 -0600 Subject: [PATCH] style: wrap YARD comment lines --- lib/buy_account_credit_form.rb | 18 ++++++++++++------ lib/credit_card_sale.rb | 18 ++++++++++++------ lib/trust_level.rb | 14 ++++++++------ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/buy_account_credit_form.rb b/lib/buy_account_credit_form.rb index 5675e68b0d40597b1bd7a6b662523a79065f1243..ab5ff1f278e91a252e291d1b6605788f87f760ee 100644 --- a/lib/buy_account_credit_form.rb +++ b/lib/buy_account_credit_form.rb @@ -7,16 +7,19 @@ class BuyAccountCreditForm # Returns a TrustLevelRepo instance, allowing for dependency injection. # Either creates a new instance given kwargs or returns the existing instance. # @param kwargs [Hash] keyword arguments. - # @option kwargs [TrustLevelRepo] :trust_level_repo An existing TrustLevelRepo instance. + # @option kwargs [TrustLevelRepo] :trust_level_repo An existing TrustLevelRepo + # instance. # @return [TrustLevelRepo] An instance of TrustLevelRepo. def self.trust_level_repo(**kwargs) kwargs[:trust_level_repo] || TrustLevelRepo.new(**kwargs) end # Factory method to create a BuyAccountCreditForm for a given customer. - # It fetches the customer's trust level to determine the maximum top-up amount. + # It fetches the customer's trust level to determine the maximum top-up + # amount. # @param customer [Customer] The customer for whom the form is being created. - # @return [EMPromise] A promise that resolves with the new form instance. + # @return [EMPromise] A promise that resolves with the + # new form instance. def self.for(customer) trust_level_repo.find(customer).then do |trust_level| customer.payment_methods.then do |payment_methods| @@ -27,8 +30,10 @@ class BuyAccountCreditForm # Initializes a new BuyAccountCreditForm. # @param balance [BigDecimal] The current balance of the customer. - # @param payment_methods [PaymentMethods] The available payment methods for the customer. - # @param max_top_up_amount [Numeric] The maximum amount the customer is allowed to top up, based on their trust level. + # @param payment_methods [PaymentMethods] The available payment methods for + # the customer. + # @param max_top_up_amount [Numeric] The maximum amount the customer is + # allowed to top up, based on their trust level. def initialize(balance, payment_methods, max_top_up_amount) @balance = balance @payment_methods = payment_methods @@ -36,7 +41,8 @@ class BuyAccountCreditForm end # Generates the form template for topping up account credit. - # The form will include a range for the amount field, constrained by a minimum of $15 + # The form will include a range for the amount field, constrained by a minimum + # of $15 # and the customer's specific maximum top-up amount. # @return [FormTemplate::OneRender] The rendered form template. def form diff --git a/lib/credit_card_sale.rb b/lib/credit_card_sale.rb index 89f9d0f914e635832e3797ecef8510177a3facf6..da1b93651a259751ec74c887e8a74fd61fa7d953 100644 --- a/lib/credit_card_sale.rb +++ b/lib/credit_card_sale.rb @@ -42,7 +42,8 @@ class AmountTooLowError < TransactionDeclinedError end end -# Error raised when a transaction is declined, potentially due to exceeding decline limits. +# Error raised when a transaction is declined, potentially due to exceeding +# decline limits. class DeclinedError < TransactionDeclinedError # @return [Integer, nil] The number of declines the customer has. attr_reader :declines @@ -110,12 +111,17 @@ class CreditCardSale protected - # Validates the transaction against customer locks, trust level, and decline history. - # @raise [TransactionDeclinedError] if the customer has made too many payments recently. - # @raise [AmountTooHighError] if the amount exceeds the trust level's maximum top-up amount. + # Validates the transaction against customer locks, trust level, and decline + # history. + # @raise [TransactionDeclinedError] if the customer has made too many payments + # recently. + # @raise [AmountTooHighError] if the amount exceeds the trust level's maximum + # top-up amount. # @raise [AmountTooLowError] if the amount is below any applicable minimum. - # @raise [DeclinedError] if the transaction is declined due to too many previous declines or other trust level restrictions. - # @return [EMPromise] A promise that resolves if validation passes, or rejects with an error. + # @raise [DeclinedError] if the transaction is declined due to too many + # previous declines or other trust level restrictions. + # @return [EMPromise] A promise that resolves if validation passes, or + # rejects with an error. def validate! EMPromise.all([ REDIS.exists("jmp_customer_credit_card_lock-#{@customer.customer_id}"), diff --git a/lib/trust_level.rb b/lib/trust_level.rb index 63bcb64f72537ccd8fdbfe3d4f469f37e85353ed..e17e9af7ac1655888b3ff1692c22fd820b3925fb 100644 --- a/lib/trust_level.rb +++ b/lib/trust_level.rb @@ -90,7 +90,8 @@ module TrustLevel # @param amount [BigDecimal] The amount of the transaction. # @param declines [Integer] The number of recent declines for the customer. # @raise [DeclinedError] if the number of declines exceeds `max_declines`. - # @raise [AmountTooHighError] if the transaction amount exceeds `max_top_up_amount`. + # @raise [AmountTooHighError] if the transaction amount exceeds + # `max_top_up_amount`. def validate_credit_card_transaction!(amount, declines) raise DeclinedError.new(declines, max_declines) if declines > max_declines return unless amount > max_top_up_amount @@ -143,7 +144,8 @@ module TrustLevel # @param amount [BigDecimal] The amount of the transaction. # @param declines [Integer] The number of recent declines for the customer. # @raise [DeclinedError] if the number of declines exceeds `max_declines`. - # @raise [AmountTooHighError] if the transaction amount exceeds `max_top_up_amount`. + # @raise [AmountTooHighError] if the transaction amount exceeds + # `max_top_up_amount`. def validate_credit_card_transaction!(amount, declines) raise DeclinedError.new(declines, max_declines) if declines > max_declines return unless amount > max_top_up_amount @@ -193,9 +195,8 @@ module TrustLevel end # Validates a credit card transaction for an Olympias trust level user. - # Users at this level have no restrictions on credit card transactions through this method. - # @param _amount [BigDecimal] The amount of the transaction (ignored). - # @param _declines [Integer] The number of recent declines (ignored). + # Users at this level have no restrictions on credit card transactions + # through this method. # @return [void] def validate_credit_card_transaction!(*) end @@ -244,7 +245,8 @@ module TrustLevel # @param amount [BigDecimal] The amount of the transaction. # @param declines [Integer] The number of recent declines for the customer. # @raise [DeclinedError] if the number of declines exceeds `max_declines`. - # @raise [AmountTooHighError] if the transaction amount exceeds `max_top_up_amount`. + # @raise [AmountTooHighError] if the transaction amount exceeds + # `max_top_up_amount`. def validate_credit_card_transaction!(amount, declines) raise DeclinedError.new(declines, max_declines) if declines > max_declines return unless amount > max_top_up_amount