Class: Kaui::Bundle
- Inherits:
-
KillBillClient::Model::Bundle
- Object
- KillBillClient::Model::Bundle
- Kaui::Bundle
- Defined in:
- app/models/kaui/bundle.rb
Class Method Summary collapse
- .find_by_id_or_key(bundle_id_or_key, account_id = nil, options = {}) ⇒ Object
- .list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) ⇒ Object
Class Method Details
.find_by_id_or_key(bundle_id_or_key, account_id = nil, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/models/kaui/bundle.rb', line 3 def self.find_by_id_or_key(bundle_id_or_key, account_id = nil, = {}) if bundle_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}/ find_by_id(bundle_id_or_key, ) else if account_id.blank? # Return the active one find_by_external_key(bundle_id_or_key, ) else # Return active and inactive ones bundles = find_all_by_account_id_and_external_key(account_id, bundle_id_or_key, ) get_active_bundle_or_latest_created(bundles) end end end |
.list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/models/kaui/bundle.rb', line 18 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, ) else find_in_batches(offset, limit, ) end end |