Class: Gringotts::DeliveryStrategies::BaseDeliveryStrategy

Inherits:
Object
  • Object
show all
Defined in:
app/models/gringotts/delivery_strategies/base_delivery_strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ BaseDeliveryStrategy

Returns a new instance of BaseDeliveryStrategy.


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/gringotts/delivery_strategies/base_delivery_strategy.rb', line 4

def initialize(h)
  delivery = h[:delivery]
    
  # unless you are in production, you should probably not be delivering codes to live phone numbers
  # change delivery/phone_number_override in config/gringotts.yml to your personal number if you are testing something in dev
  # or just set delivery/enabled to false if you don't want to deliver any codes at all
  # note: there are some legit circumstances where you want to send in dev (like
  # TODO: could this be refactored so that the delivery object decides this, instead of the strategy ?
  if Rails.env.production?
    @phone_number = delivery.phone_number
  elsif Rails.env.development?
    @phone_number = Gringotts::Config.delivery['phone_number_override']
  else
    @phone_number = nil
  end
  
  @code = delivery.code.value
end

Instance Method Details

#deliver!Object

Raises:

  • (NotImplementedError)

23
24
25
# File 'app/models/gringotts/delivery_strategies/base_delivery_strategy.rb', line 23

def deliver!
  raise NotImplementedError
end