module CanUse
Overview
CanUse is a minimalist feature toggle for Crystal.
Defined in:
can_use.crConstant Summary
-
VERSION =
"0.2.0"
Class Method Summary
-
.configure(&)
Sets the configuration for
CanUse
-
.disable(name : String)
Disables the feature and returns
false
. -
.enable(name : String)
Enables the feature and returns
true
. -
.feature?(name : YAML::Any::Type)
Returns
true
orfalse
based on the feature configuration. -
.feature?(name : String, &)
Evaluates the block if the feature returns
true
..
Class Method Detail
def self.configure(&)
#
Sets the configuration for CanUse
CanUse.configure do |config|
config.environment = "development"
config.file = "config/features.yml"
end
def self.disable(name : String)
#
Disables the feature and returns false
.
CanUse.disable("feature_two") # => false
def self.enable(name : String)
#
Enables the feature and returns true
.
CanUse.enable("feature_three") # => true
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
def self.feature?(name : String, &)
#
Evaluates the block if the feature returns true
..
CanUse.feature?("feature_one") do
puts "Yeah, I cam use!"
end