Class: Kaui::Bundle

Inherits:
KillBillClient::Model::Bundle
  • Object
show all
Defined in:
app/models/kaui/bundle.rb

Class Method Summary collapse

Class Method Details

.find_by_id_or_key(bundle_id_or_key, options = {}) ⇒ Object


3
4
5
6
7
8
9
10
11
# File 'app/models/kaui/bundle.rb', line 3

def self.find_by_id_or_key(bundle_id_or_key, options = {})
  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}/
    bundle = find_by_id(bundle_id_or_key, options) rescue nil
    return bundle unless bundle.nil?
  end

  # Return the active one
  find_by_external_key(bundle_id_or_key, false, options)
end

.list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) ⇒ Object


13
14
15
16
17
18
19
# File 'app/models/kaui/bundle.rb', line 13

def self.list_or_search(search_key = nil, offset = 0, limit = 10, options = {})
  if search_key.present?
    find_in_batches_by_search_key(search_key, offset, limit, options)
  else
    find_in_batches(offset, limit, options)
  end
end