module CanUse

Overview

CanUse is a minimalist feature toggle for Crystal.

Defined in:

can_use.cr

Constant Summary

VERSION = "0.2.0"

Class Method Summary

Class Method Detail

def self.configure(&) #

Sets the configuration for CanUse

CanUse.configure do |config|
  config.environment = "development"
  config.file = "config/features.yml"
end

[View source]
def self.disable(name : String) #

Disables the feature and returns false.

CanUse.disable("feature_two") # => false

[View source]
def self.enable(name : String) #

Enables the feature and returns true.

CanUse.enable("feature_three") # => true

[View source]
def self.feature?(name : YAML::Any::Type) #

Returns true or false based on the feature configuration. Otherwise, reads from the default value.

if CanUse.feature?("feature_one")
  # do_something
end

[View source]
def self.feature?(name : String, &) #

Evaluates the block if the feature returns true..

CanUse.feature?("feature_one") do
  puts "Yeah, I cam use!"
end

[View source]