New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

determinator-context

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

determinator-context

  • 0.1.11
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Determinator Context

This is a gem to manage Determinator context objects.

It allows you to define the actors that will be determinated upon in a single place in the controller, where they can be tested; then, the ID to be determinated upon are decided either by pointing to an attribute in code, or with a structured setting in the feature itself.

Installation

Add this line to your application's Gemfile:

source "https://8Sshw-M7Dp0iGmkGphMxS4s7BCCuI@gem.fury.io/deliveroo/" do
  gem 'determinator-context'
end

And then execute:

$ bundle

Usage

The simplest way to set up a context is to use the included helper in your controllers. For example:

class ApplicationController < ActionController::Base
  include Determinator::Context::Helpers

  determinator_actor(:request) do
    Determinator::Models::Request.new(
      uid: 'abc', customer: {guid: 'foo', sticky_guid: 'bar', session_guid: nil}
    )
  end

  determinator_actor(:customer) do
    next nil unless current_user.present?

    Determinator::Models::Customer.new(
      id: current_user.id,
      email: current_user.email,
      employee: current_user.employee
    )
  end
end

class MenuController < ApplicationController
  include Determinator::Context::Helpers

  determinator_actor(:restaurant) do
    # If 'to_determinator' is a method on the model
    # which returns the constructed object
    restaurant.to_determinator
  end

end

Then, if the feature has a structured_bucket set, you can just use the determinator context to determinate:

determinator_context.which_variant('test_feature')

If the feature is not structured, or for some reason you want to override the structured bucket, you can do:

determinator_context.using('request.customer.guid').which_variant('test_feature')

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to GemFury.

FAQs

Package last updated on 05 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc