Class: Hamburglar::Config
- Inherits:
-
Object
- Object
- Hamburglar::Config
- Defined in:
- lib/hamburglar/config.rb
Overview
The Hamburglar::Config class stores configuration variables used to generate fraud reports.
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Credentials that should be used when communicating with upstream APIs.
-
#fraud_proc ⇒ Object
An optional Proc that will be used to evaluate ‘Hamburglar::Report#fraud?` if set.
-
#fraud_score ⇒ Object
The score that should be considered fraud.
-
#gateway ⇒ Object
The gateway used when generating fraud reports via ‘Hamburglar::Report.new`.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
Create a new Config instance and set some defaults.
Constructor Details
#initialize ⇒ Config
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
#credentials ⇒ Object
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_proc ⇒ Object
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_score ⇒ Object
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 |
#gateway ⇒ Object
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 |