0.0
The project is in a healthy, maintained state
MintCondition provides a minimal, observable entitlements engine with capabilities, rulesets, and structured decisions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

MintCondition

MintCondition is a lightweight, framework-agnostic entitlements engine. It lets you define capabilities, evaluate plan rules, and return structured decisions (booleans and limits) without tying your app to any specific billing or authorization system.

Installation

Add this line to your application's Gemfile:

gem "mint_condition"

And then execute:

bundle install

Usage

Register capabilities:

MintCondition::Capabilities.register(
  "messages.send",
  "messages.max",
  "reports.export"
)

Define a ruleset (per plan or tier):

ruleset = MintCondition::Ruleset.build do
  allow "messages.send"
  limit "messages.max", 1000
  deny "reports.export"
end

Evaluate entitlements:

checker = MintCondition::Checker.new(ruleset: ruleset, context: { plan: "pro" })

checker.allowed?("messages.send")
# => true

decision = checker.allow("messages.max")
decision.allowed?
# => true
decision.value
# => 1000

You can also use the module-level helpers:

MintCondition.allowed?("messages.send", ruleset: ruleset)

Configure unknown capability behavior and instrumentation:

MintCondition.configure do |config|
  config.unknown_capability = :allow # :deny or :raise
  config.instrumenter = lambda do |event, payload|
    # hook into your logger or tracer
  end
end

Use MintCondition::Limits::UNLIMITED to represent no limits in a ruleset.

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 the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome. See CONTRIBUTING.md for details.

Security

Please report vulnerabilities privately. See SECURITY.md for details.

License

The gem is available as open source under the terms of the MIT License.