Class: Heya::Campaigns::Step

Inherits:
OpenStruct
  • Object
show all
Includes:
GlobalID::Identification
Defined in:
lib/heya/campaigns/step.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, campaign:, position:, action:, wait:, segment:, queue:, params: {}) ⇒ Step

Returns a new instance of Step.



15
16
17
18
19
20
# File 'lib/heya/campaigns/step.rb', line 15

def initialize(id:, name:, campaign:, position:, action:, wait:, segment:, queue:, params: {})
  super
  if action.respond_to?(:validate_step)
    action.validate_step(self)
  end
end

Class Method Details

.find(id) ⇒ Object



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

def self.find(id)
  campaign_name, _step_name = id.to_s.split("/")
  campaign_name.constantize.steps.find { |s| s.id == id }
end

Instance Method Details

#campaign_nameObject



30
31
32
# File 'lib/heya/campaigns/step.rb', line 30

def campaign_name
  @campaign_name ||= campaign.name
end

#gidObject



22
23
24
# File 'lib/heya/campaigns/step.rb', line 22

def gid
  to_gid(app: "heya").to_s
end

#in_segment?(user) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/heya/campaigns/step.rb', line 26

def in_segment?(user)
  Heya.in_segments?(user, *campaign.__segments, segment)
end