Sha256: 6de8877e1271bf1fcd5e740992a2a7e475f0e98dc6dc0efe3532b7c8c63b6e16

Contents?: true

Size: 736 Bytes

Versions: 24

Compression:

Stored size: 736 Bytes

Contents

module Verdict
  module Segmenters
    class StaticSegmenter < BaseSegmenter

      def register_group(handle, subject_identifiers)
        Group.new(experiment, handle, subject_identifiers)
      end

      def assign(identifier, subject, context)
        groups.values.find { |group| group.subject_identifiers.include?(identifier) }
      end

      class Group < Verdict::Group
        attr_reader :subject_identifiers

        def initialize(experiment, handle, subject_identifiers)
          super(experiment, handle)
          @subject_identifiers = subject_identifiers
        end

        def as_json(options = {})
          super(options).merge(subject_identifiers: subject_identifiers)
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
verdict-0.3.2 lib/verdict/segmenters/static_segmenter.rb
verdict-0.3.1 lib/verdict/segmenters/static_segmenter.rb
verdict-0.3.0 lib/verdict/segmenters/static_segmenter.rb
verdict-0.2.1 lib/verdict/segmenters/static_segmenter.rb