Module: Heimdall

Includes:
RuneFinder
Defined in:
lib/heimdall.rb,
lib/heimdall/version.rb,
lib/heimdall/rune_finder.rb,
lib/generators/heimdall/migration_helper.rb,
lib/generators/heimdall/install_generator.rb

Overview

Heimdall is a simple feature gate library.

Heimdall provides a mechanism to control access to features in your application. It uses a tree structure to represent feature flags and allows you to build and manage feature trees from templates. The library also includes access control checks to ensure that only authorized users can access certain features.

## Features

  • Define and manage feature flags using a tree structure.

  • Build feature trees from JSON templates.

  • Perform access control checks based on feature flags.

## Usage

“‘ruby # Define a policy class class MyPolicy

def some_feature?
  # logic to check access
end

end

# Check access to a feature Heimdall.check_access?(query: :some_feature?, klass: MyPolicy) “‘

Defined Under Namespace

Modules: Generators, RuneFinder Classes: Error

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Methods included from RuneFinder

#rune_class

Class Method Details

.worthy?(query:, klass:) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



41
42
43
44
45
46
# File 'lib/heimdall.rb', line 41

def worthy?(query:, klass:)
  policy = klass.new
  raise AccessDeniedError.new({ query: query, klass: klass }) unless policy.public_send(query)

  true
end