Giter VIP home page Giter VIP logo

caseflow-commons's Introduction

Caseflow

Common libs for the Caseflow suite of applications.

Installation

Add this line to your application's Gemfile:

gem 'caseflow'

And then execute:

$ bundle

Or install it yourself as:

$ gem install caseflow

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake 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 rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/department-of-veterans-affairs/caseflow-commons.

Feature Toggle

To enable and disable features using rails c. Example usage:

# users
user1 = User.new(regional_office: "RO03")
user2 = User.new(regional_office: "RO04")

# enable for everyone
FeatureToggle.enable!(:apple)
=> true
FeatureToggle.enabled?(:apple, user1)
=> true

# enable for a list of regional offices
FeatureToggle.enable!(:apple, regional_offices: ["RO03", "RO08"])
=> true

# add more regional offices to the same feature
FeatureToggle.enable!(:apple, regional_offices: ["RO03", "RO09"])
=> true

# view the details
FeatureToggle.details_for(:apple)
=> { :regional_offices => ["RO03", "RO08", "RO09"] }

# check if the feature is enabled for a given user
FeatureToggle.enabled?(:apple, user1)
=> true
FeatureToggle.enabled?(:apple, user2)
=> false

# disable a few regional offices
FeatureToggle.disable!(:apple, regional_offices: ["RO03", "RO09"])
=> true
FeatureToggle.details_for(:apple)
=> { :regional_offices =>["RO08"] }

# List all toggle features
FeatureToggle.features
=> [:apple]

Functions

Functions module is used to grant and deny user permissions/roles. Example usage:

# Add a role to the list of users and overwrite the list before
# Caution: Empty array will remove all users who were granted the function.
Functions.grant!("Reader", users: ["CSS_ID_1", "CSS_ID_2"])
=> true

# Deny a role
Functions.deny!("Reader", users: ["CSS_ID_1"])
=> true

# Method to check if a given function is granted for a user
 Functions.granted?("Reader", "CSS_ID_1")
=> false

# Method to check if a given function is denied to a user
 Functions.denied?("Reader", "CSS_ID_1")
=> true

# Returns a hash result for a given function
Functions.details_for("Reader")
=> {:granted=>["CSS_ID_2"], :denied=>["CSS_ID_1"]}

# Returns a hash result for all functions with granted and denied users
Functions.list_all
=> {"Reader"=>{:granted=>["CSS_ID_2"], :denied=>["CSS_ID_1"]}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.