Class: Kaui::TagDefinition

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

Constant Summary collapse

ALL_OBJECT_TYPES =

See org.killbill.billing.ObjectType in killbill-api

%w(ACCOUNT
ACCOUNT_EMAIL
BLOCKING_STATES
BUNDLE
CUSTOM_FIELD
INVOICE
PAYMENT
TRANSACTION
INVOICE_ITEM
INVOICE_PAYMENT
SUBSCRIPTION
SUBSCRIPTION_EVENT
PAYMENT_ATTEMPT
PAYMENT_METHOD
REFUND
TAG
TAG_DEFINITION
TENANT
TENANT_KVS)

Instance Method Summary collapse

Instance Method Details

#<=>(tag_definition) ⇒ Object


44
45
46
47
48
49
# File 'app/models/kaui/tag_definition.rb', line 44

def <=>(tag_definition)
  # System tags last
  return 1 if is_system_tag? and !tag_definition.is_system_tag?
  return -1 if !is_system_tag? and tag_definition.is_system_tag?
  name <=> tag_definition.name
end

#is_system_tag?Boolean

Returns:

  • (Boolean)

30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/kaui/tag_definition.rb', line 30

def is_system_tag?
  return false unless id.present?
  last_group = id.split('-')[4]

  is_system_tag = true
  last_group.split(//).each_with_index do |c, i|
    unless (c == '0' and i < 11) or (c.to_i > 0 and i == 11)
      is_system_tag = false
      break
    end
  end
  is_system_tag
end

#pretty_applicable_object_typesObject


51
52
53
# File 'app/models/kaui/tag_definition.rb', line 51

def pretty_applicable_object_types
  applicable_object_types == ALL_OBJECT_TYPES ? 'Any' : applicable_object_types.join(', ')
end