Class: Dhan::Orders::PlaceOrder
- Inherits:
-
Object
- Object
- Dhan::Orders::PlaceOrder
- Defined in:
- lib/generators/dhanhq/install/templates/place_order_service.rb
Overview
Places a Dhan order via the bang variant, so a rejection raises a specific, catchable error instead of Order.place's ambiguous nil/false/ErrorObject return.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(params) ⇒ PlaceOrder
constructor
A new instance of PlaceOrder.
Constructor Details
#initialize(params) ⇒ PlaceOrder
Returns a new instance of PlaceOrder.
9 10 11 |
# File 'lib/generators/dhanhq/install/templates/place_order_service.rb', line 9 def initialize(params) @params = params end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/dhanhq/install/templates/place_order_service.rb', line 13 def call DhanHQ::Models::Order.place!(@params) rescue DhanHQ::OrderError => e Rails.logger.error("Dhan order rejected: #{e.}") raise rescue DhanHQ::RiskViolation => e Rails.logger.warn("Dhan risk check blocked the order: #{e.}") raise end |