module CanUse
Overview
CanUse is a minimalist feature toggle for Crystal.
Defined in:
can_use.crConstant Summary
-
VERSION =
"0.1.0"
Class Method Summary
-
.configure(&)
Sets the configuration for
CanUse -
.feature?(name : String)
Returns
trueorfalsebased 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
Example
CanUse.configure do |config|
config.environment = "development"
config.file = "config/features.yml"
end
def self.feature?(name : String)
#
Returns true or false based on the feature configuration.
Otherwise, reads from the default value.
Example
if CanUse.feature?("feature_one")
# do_something
end
def self.feature?(name : String, &)
#
Evaluates the block if the feature returns true..
Example
CanUse.feature?("feature_one") do
puts "Yeah, I cam use!"
end