Minicontext
Mimicontext is a DSL kit.
Installation
Add this line to your application's Gemfile:
gem 'minicontext'
And then execute:
$ bundle
Or install it yourself as:
$ gem install minicontext
Usage
build:
require 'minicontext'
root = Minicontext::Context.new
env = Minicontext::Environment.new(1)
root.task(:a) { 10 }
# or
root.context(:i) do
task(:a) { 100 }
task(:b) { 'b' }
end
# or
root.load <source>
invoke:
root[:a].value.(env)
#=> 10
root[:i][:a].value.(env)
# => 100
root[:a]
# => #<Minicontext::Router::Just ...>
root[:a].value
# => #<Proc ...>
root[:b]
# => #<Minicontext::Router::Noting ...>
root[:b].value
# => nil
License
The gem is available as open source under the terms of the MIT License.