Sha256: c4515189a3278372a57afcc11a70282afe50fea0e26d9eda5b7c439155604e2b

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

module ABPlugin
  module Helper
    
    private
    
    def a_b(variant, &block)
      block.call if block_given? && ABPlugin.select_variant?(@a_b_selections, variant)
    end
    
    def a_b_script_tag
      token = Digest::SHA256.hexdigest(ABPlugin.session_id + ABPlugin.user_token)
      variants = @a_b_selections.values.collect { |v| "variants[]=#{v}" }.join '&'
      url = ABPlugin.url + "/visit.js?session_id=#{ABPlugin.session_id}&token=#{token}&#{variants}"
      "<script src=\"#{url}\" type=\"text/javascript\"></script>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
a_b_plugin-0.1.0 lib/a_b_plugin/helper.rb