Class: IronBank::Describe::ExcludedFields::ExtractFromMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_bank/describe/excluded_fields/extract_from_message.rb

Overview

rubocop:disable Style/ClassAndModuleChildren

Constant Summary collapse

FAULT_FIELD_MESSAGES =
Regexp.union(
  # Generic fault field
  /invalid field for query: \w+\.(\w+)/,
  # Invoice Bill Run is not selectable in ZOQL
  /Cannot use the (BillRunId) field in the select clause/,
  # Invoice Body, implemented as a separate call
  /Can only query one invoice (body) at a time/,
  # Catalog tier should only query the price field
  /use Price or (DiscountAmount) or (DiscountPercentage)/,
  # Catalog plan currencies, implemented as a separate call
  /When querying for (active currencies)/,
  # Catalog charge rollover balance
  /You can only query (RolloverBalance) in particular/,
  # (Subscription) charge should only query the price field
  /
    (OveragePrice),
    \ Price,
    \ (IncludedUnits),
    \ (DiscountAmount)
    \ or\ (DiscountPercentage)
  /x
).freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(message) ⇒ Object



35
36
37
# File 'lib/iron_bank/describe/excluded_fields/extract_from_message.rb', line 35

def self.call(message)
  new(message).call
end

Instance Method Details

#callObject



39
40
41
42
43
44
# File 'lib/iron_bank/describe/excluded_fields/extract_from_message.rb', line 39

def call
  return unless FAULT_FIELD_MESSAGES.match(message)

  Regexp.last_match.captures.compact.
    map { |capture| capture.delete(" ") }
end