Sha256: 5fa237f627ecea572442e9a903ad3299bc97e89b06ee57d1c3af5b1d7e473cf8

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "heya/version"
require "heya/active_record_extension"
require "heya/engine"
require "heya/config"
require "heya/campaigns/action"
require "heya/campaigns/actions/email"
require "heya/campaigns/actions/block"
require "heya/campaigns/base"
require "heya/campaigns/queries"
require "heya/campaigns/scheduler"
require "heya/campaigns/step"
require "heya/campaigns/step_action_job"

module Heya
  extend self

  attr_accessor :campaigns
  self.campaigns = []

  def register_campaign(klass)
    campaigns.push(klass) unless campaigns.include?(klass)
  end

  def unregister_campaign(klass)
    campaigns.delete(klass)
  end

  def configure
    yield(config) if block_given?
    config
  end

  def config
    @config ||= Config.new
  end

  def in_segments?(user, *segments)
    return false if segments.any? { |s| !in_segment?(user, s) }
    true
  end

  def in_segment?(user, segment)
    return true if segment.nil?
    return user.send(segment) if segment.is_a?(Symbol)
    segment.call(user)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
heya-0.12.0 lib/heya.rb
heya-0.11.0 lib/heya.rb
heya-0.10.0 lib/heya.rb
heya-0.9.0 lib/heya.rb
heya-0.8.0 lib/heya.rb
heya-0.7.0 lib/heya.rb
heya-0.6.1 lib/heya.rb
heya-0.6.0 lib/heya.rb
heya-0.5.3 lib/heya.rb
heya-0.5.2 lib/heya.rb
heya-0.5.1 lib/heya.rb
heya-0.5.0 lib/heya.rb
heya-0.4.0 lib/heya.rb