Class: Workarea::Checkout::Fraud::Analyzer
- Inherits:
-
Object
- Object
- Workarea::Checkout::Fraud::Analyzer
- Defined in:
- app/models/workarea/checkout/fraud/analyzer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#checkout ⇒ Object
readonly
Returns the value of attribute checkout.
Instance Method Summary collapse
- #decide! ⇒ Object
- #error_decision(message) ⇒ Object
-
#initialize(checkout) ⇒ Analyzer
constructor
A new instance of Analyzer.
-
#make_decision(checkout = nil) ⇒ Workarea::Order::FraudDecision
Gets a decision about the fraudlence of a given checkout.
Constructor Details
#initialize(checkout) ⇒ Analyzer
Returns a new instance of Analyzer.
11 12 13 |
# File 'app/models/workarea/checkout/fraud/analyzer.rb', line 11 def initialize(checkout) @checkout = checkout end |
Instance Attribute Details
#checkout ⇒ Object (readonly)
Returns the value of attribute checkout.
5 6 7 |
# File 'app/models/workarea/checkout/fraud/analyzer.rb', line 5 def checkout @checkout end |
Instance Method Details
#decide! ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/models/workarea/checkout/fraud/analyzer.rb', line 15 def decide! begin decision = make_decision.tap { |r| r.analyzer = self.class.name } rescue => e decision = error_decision(e.) ensure order.set_fraud_decision!(decision) end end |
#error_decision(message) ⇒ Object
35 36 37 38 39 40 |
# File 'app/models/workarea/checkout/fraud/analyzer.rb', line 35 def error_decision() Workarea::Order::FraudDecision.new( decision: :no_decision, message: "An error occured during the fraud check: #{}" ) end |
#make_decision(checkout = nil) ⇒ Workarea::Order::FraudDecision
Gets a decision about the fraudlence of a given checkout
31 32 33 |
# File 'app/models/workarea/checkout/fraud/analyzer.rb', line 31 def make_decision(checkout = nil) raise(NotImplementedError, "#{self.class} must implement the #make_decision method") end |