Class: Heya::Campaigns::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/heya/campaigns/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user:, step:) ⇒ Action

Returns a new instance of Action.



6
7
8
# File 'lib/heya/campaigns/action.rb', line 6

def initialize(user:, step:)
  @user, @step = user, step
end

Instance Attribute Details

#stepObject (readonly)

Returns the value of attribute step.



10
11
12
# File 'lib/heya/campaigns/action.rb', line 10

def step
  @step
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'lib/heya/campaigns/action.rb', line 10

def user
  @user
end

Instance Method Details

#buildObject

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/heya/campaigns/action.rb', line 12

def build
  raise NotImplementedError, "Please implement #build on subclass of Heya::Campaigns::Action."
end

#deliver_laterObject



20
21
22
23
24
# File 'lib/heya/campaigns/action.rb', line 20

def deliver_later
  StepActionJob
    .set(queue: step.queue)
    .perform_later(step.campaign.class.name, user, step)
end

#deliver_nowObject



16
17
18
# File 'lib/heya/campaigns/action.rb', line 16

def deliver_now
  build.deliver
end