Class: Hamburglar::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/hamburglar/config.rb

Overview

The Hamburglar::Config class stores configuration variables used to generate fraud reports.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Create a new Config instance and set some defaults



54
55
56
57
58
# File 'lib/hamburglar/config.rb', line 54

def initialize
  @gateway     = :min_fraud
  @credentials = {}
  @fraud_score = 2.5
end

Instance Attribute Details

#credentialsObject

Credentials that should be used when communicating with upstream APIs.

This should be a Hash. When a query is sent to a Gateway, this Hash will be merged in *if* it's keys exist in Gateway#optional_params

Example:

# Set credentials:
config.credentials = { :license_key => 's3cretz' }

# Get credentials
config.credentials


28
29
30
# File 'lib/hamburglar/config.rb', line 28

def credentials
  @credentials
end

#fraud_procObject

An optional Proc that will be used to evaluate `Hamburglar::Report#fraud?` if set

Example:

# Set proc
config.fraud_proc = lambda { |report| report.distance > 500 }

# Get proc
config.fraud_proc


51
52
53
# File 'lib/hamburglar/config.rb', line 51

def fraud_proc
  @fraud_proc
end

#fraud_scoreObject

The score that should be considered fraud. This score will be checked when `Hamburglar::Report#fraud?` is called, unless `config.fraud_proc` is set

Example:

# Set fraud score
config.fraud_score = 5

# Get fraud score
config.fraud_score


40
41
42
# File 'lib/hamburglar/config.rb', line 40

def fraud_score
  @fraud_score
end

#gatewayObject

The gateway used when generating fraud reports via `Hamburglar::Report.new`.

Example:

# Set gateway
config.gateway = :min_fraud

# Get gateway
config.gateway


14
15
16
# File 'lib/hamburglar/config.rb', line 14

def gateway
  @gateway
end