Class: Kaui::Account
- Inherits:
-
KillBillClient::Model::Account
- Object
- KillBillClient::Model::Account
- Kaui::Account
- Defined in:
- app/models/kaui/account.rb
Instance Attribute Summary collapse
-
#bill_cycle_day_local ⇒ Object
Returns the value of attribute bill_cycle_day_local.
-
#phone ⇒ Object
Returns the value of attribute phone.
Class Method Summary collapse
- .find_by_id_or_key(account_id_or_key, with_balance, with_balance_and_cba, options = {}) ⇒ Object
- .list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) ⇒ Object
Instance Method Summary collapse
- #balance_to_money ⇒ Object
- #cba_to_money ⇒ Object
- #check_account_details_bill_cycle_day_local ⇒ Object
- #check_account_details_phone ⇒ Object
- #persisted? ⇒ Boolean
Instance Attribute Details
#bill_cycle_day_local ⇒ Object
Returns the value of attribute bill_cycle_day_local.
5 6 7 |
# File 'app/models/kaui/account.rb', line 5 def bill_cycle_day_local @bill_cycle_day_local end |
#phone ⇒ Object
Returns the value of attribute phone.
5 6 7 |
# File 'app/models/kaui/account.rb', line 5 def phone @phone end |
Class Method Details
.find_by_id_or_key(account_id_or_key, with_balance, with_balance_and_cba, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/kaui/account.rb', line 19 def self.find_by_id_or_key(account_id_or_key, with_balance, with_balance_and_cba, = {}) if account_id_or_key =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/ begin find_by_id(account_id_or_key, with_balance, with_balance_and_cba, ) rescue StandardError => e begin # account_id_or_key looked like an id, but maybe it's an external key (this will happen in tests)? find_by_external_key(account_id_or_key, with_balance, with_balance_and_cba, ) rescue StandardError => _ # Nope - raise the initial exception raise e end end else find_by_external_key(account_id_or_key, with_balance, with_balance_and_cba, ) end end |
.list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/models/kaui/account.rb', line 37 def self.list_or_search(search_key = nil, offset = 0, limit = 10, = {}) if search_key.present? find_in_batches_by_search_key(search_key, offset, limit, true, false, ) else find_in_batches(offset, limit, true, false, ) end end |
Instance Method Details
#balance_to_money ⇒ Object
45 46 47 |
# File 'app/models/kaui/account.rb', line 45 def balance_to_money Kaui::Base.to_money(account_balance.abs, currency) end |
#cba_to_money ⇒ Object
49 50 51 |
# File 'app/models/kaui/account.rb', line 49 def cba_to_money Kaui::Base.to_money(account_cba.abs, currency) end |
#check_account_details_bill_cycle_day_local ⇒ Object
13 14 15 16 17 |
# File 'app/models/kaui/account.rb', line 13 def check_account_details_bill_cycle_day_local return true if bill_cycle_day_local.to_i.between?(1, 31) false end |
#check_account_details_phone ⇒ Object
7 8 9 10 11 |
# File 'app/models/kaui/account.rb', line 7 def check_account_details_phone return true if phone =~ /\A(?:\+?\d{1,3}\s*-?)?\(?(?:\d{3})?\)?[- ]?\d{3}[- ]?\d{4}\z/i false end |
#persisted? ⇒ Boolean
53 54 55 |
# File 'app/models/kaui/account.rb', line 53 def persisted? !account_id.blank? end |