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].freeze

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



47
48
49
50
51
52
53
# File 'app/models/kaui/tag_definition.rb', line 47

def <=>(other)
  # System tags last
  return 1 if system_tag? && !other.system_tag?
  return -1 if !system_tag? && other.system_tag?

  name <=> other.name
end

#pretty_applicable_object_typesObject



55
56
57
# File 'app/models/kaui/tag_definition.rb', line 55

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

#system_tag?Boolean

Returns:

  • (Boolean)


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

def system_tag?
  return false unless id.present?

  last_group = id.split('-')[4]

  is_system_tag = true
  last_group.chars.each_with_index do |c, i|
    unless ((c == '0') && (i < 11)) || (c.to_i.positive? && (i == 11))
      is_system_tag = false
      break
    end
  end
  is_system_tag
end