Class: Karafka::Web::Tracking::BaseContract

Inherits:
Core::Contractable::Contract
  • Object
show all
Defined in:
lib/karafka/web/tracking/base_contract.rb

Overview

Base for all the metric related contracts

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configureObject

This layer is not for users extensive feedback, thus we can easily use the minimum error messaging there is.



11
12
13
14
15
16
17
18
19
# File 'lib/karafka/web/tracking/base_contract.rb', line 11

def configure
  super do |config|
    config.error_messages = YAML.safe_load(
      File.read(
        File.join(Karafka::Web.gem_root, 'config', 'locales', 'errors.yml')
      )
    ).fetch('en').fetch('validations').fetch('web')
  end
end

Instance Method Details

#validate!(data) ⇒ Boolean

Returns true if all good.

Parameters:

  • data (Hash)

    data for validation

Returns:

  • (Boolean)

    true if all good

Raises:

  • (Errors::ContractError)

    invalid report



25
26
27
# File 'lib/karafka/web/tracking/base_contract.rb', line 25

def validate!(data)
  super(data, Errors::Tracking::ContractError)
end