lib/ledgerizer/locking.rb
def grab_locks
        account_balances = @accounts.map do |account|
          Ledgerizer::Account.find_by_executable_account(account, lock: true)
        end

        if account_balances.any?(&:nil?)
          accts = @accounts.zip(account_balances)
                           .select { |_account, account_balance| account_balance.nil? }
                           .collect { |account, _account_balance| account }
          @accounts_without_balances = accts
          false
        else
          self.locks = Hash[*@accounts.zip(account_balances).flatten]
          true
        end
      end
# Grab a lock on the account balance record for each account.
#
# If all the account balance records exist, set locks to a hash mapping
# accounts to account balances, and return true.
#
# If one or more account balance records don't exist, set
# accounts_with_balances to the corresponding accounts, and return false.
Grab a lock on the account balance record for each account.
If all the account balance records exist, set locks to a hash mapping
accounts to account balances, and return true.

If one or more account balance records don't exist, set
accounts_with_balances to the corresponding accounts, and return false.
Grab a lock on the account balance record for each account . If all the account balance records exist set locks to a hash mapping accounts to account balances and return true . If one or more account balance records don ' t exist set accounts_with_balances to the corresponding accounts and return false .
def grab_locks
        account_balances = @accounts.map do |account|
          Ledgerizer::Account.find_by_executable_account(account, lock: true)
        end
        if account_balances.any?(&:nil?)
          accts = @accounts.zip(account_balances)
                           .select { |_account, account_balance| account_balance.nil? }
                           .collect { |account, _account_balance| account }
          @accounts_without_balances = accts
          false
        else
          self.locks = Hash[*@accounts.zip(account_balances).flatten]
          true
        end
      end
def grab_locks account_balances = @accounts . map do | account | Ledgerizer :: Account . find_by_executable_account ( account , lock : true ) end if account_balances . any? ( & :nil? ) accts = @accounts . zip ( account_balances ) . select { | _account , account_balance | account_balance . nil? } . collect { | account , _account_balance | account } @accounts_without_balances = accts false else self . locks = Hash [ * @accounts . zip ( account_balances ) . flatten ] true end end
Grab a lock on the account balance record for each account.
Grab a lock on the account balance record for each account .