Sha256: f653eeeb9be7199618d6e37a0587e2149fa7f72a0885850423790d4a5633f97a

Contents?: true

Size: 1.13 KB

Versions: 33

Compression:

Stored size: 1.13 KB

Contents

module Determinator
  # A decorator to provide syntactic sugar for Determinator::Control.
  # Useful for contexts where the actor remains constant (eg. inside
  # the request cycle in a webapp)
  class ActorControl
    attr_reader :id, :guid, :default_properties

    # @see Determinator::Control#for_actor
    def initialize(controller, id: nil, guid: nil, default_properties: {})
      @id = id
      @guid = guid
      @default_properties = default_properties
      @controller = controller
    end

    # @see Determinator::Control#which_variant
    def which_variant(name, properties: {})
      controller.which_variant(
        name,
        id: id,
        guid: guid,
        properties: default_properties.merge(properties)
      )
    end

    # @see Determinator::Control#feature_flag_on?
    def feature_flag_on?(name, properties: {})
      controller.feature_flag_on?(
        name,
        id: id,
        guid: guid,
        properties: default_properties.merge(properties)
      )
    end

    def inspect
      "#<Determinator::ActorControl id=#{id.inspect} guid=#{guid.inspect}>"
    end

    private

    attr_reader :controller
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
determinator-2.9.2 lib/determinator/actor_control.rb
determinator-2.9.1 lib/determinator/actor_control.rb
determinator-2.9.0 lib/determinator/actor_control.rb
determinator-2.8.0 lib/determinator/actor_control.rb
determinator-2.7.1 lib/determinator/actor_control.rb
determinator-2.7.0 lib/determinator/actor_control.rb
determinator-2.6.0 lib/determinator/actor_control.rb
determinator-2.5.4 lib/determinator/actor_control.rb
determinator-2.5.3 lib/determinator/actor_control.rb
determinator-2.5.2 lib/determinator/actor_control.rb
determinator-2.5.1 lib/determinator/actor_control.rb
determinator-2.5.0 lib/determinator/actor_control.rb
determinator-2.4.4 lib/determinator/actor_control.rb
determinator-2.4.3 lib/determinator/actor_control.rb
determinator-2.4.2 lib/determinator/actor_control.rb
determinator-2.4.0 lib/determinator/actor_control.rb
determinator-2.3.1 lib/determinator/actor_control.rb
determinator-2.3.0 lib/determinator/actor_control.rb
determinator-2.2.1 lib/determinator/actor_control.rb
determinator-2.2.0 lib/determinator/actor_control.rb