Class: Hamburglar::Report
- Inherits:
-
Object
- Object
- Hamburglar::Report
- Defined in:
- lib/hamburglar/report.rb
Overview
Hamburglar::Report is the main class for generating fraud reports
Instance Attribute Summary (collapse)
-
- (Object) params
readonly
Parameters that will be used to generate this fraud report.
-
- (Object) response
readonly
Response from gateway.
Instance Method Summary (collapse)
- - (Boolean) fraud?
-
- (Report) initialize(params = {})
constructor
A new instance of Report.
- - (Object) method_missing(method, *args, &block)
- - (Boolean) respond_to?(key)
Constructor Details
- (Report) initialize(params = {})
A new instance of Report
10 11 12 13 14 |
# File 'lib/hamburglar/report.rb', line 10 def initialize(params = {}) @gateway = params.delete(:gateway) || Hamburglar.config.gateway @params = params @response = generate_report! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block)
16 17 18 19 20 21 22 |
# File 'lib/hamburglar/report.rb', line 16 def method_missing(method, *args, &block) if @response && @response[method.to_sym] @response[method.to_sym] else super end end |
Instance Attribute Details
- (Object) params (readonly)
Parameters that will be used to generate this fraud report
5 6 7 |
# File 'lib/hamburglar/report.rb', line 5 def params @params end |
- (Object) response (readonly)
Response from gateway
8 9 10 |
# File 'lib/hamburglar/report.rb', line 8 def response @response end |
Instance Method Details
- (Boolean) fraud?
28 29 30 31 32 33 34 35 36 |
# File 'lib/hamburglar/report.rb', line 28 def fraud? @fraud = true if @response.nil? || @response.empty? return @fraud if @fraud if Hamburglar.config.fraud_proc.nil? @fraud = @response[:score].to_f >= Hamburglar.config.fraud_score.to_f else @fraud = Hamburglar.config.fraud_proc.call(self) == true end end |
- (Boolean) respond_to?(key)
24 25 26 |
# File 'lib/hamburglar/report.rb', line 24 def respond_to?(key) @response.has_key?(key) || super end |