Jace
Yard Documentation
https://www.rubydoc.info/gems/jace/0.1.1
Jace is designed to have a semi event driven development
Using Jace::Registry
, event handlers can be registered to events, and when an event
is triggered, the block that triggers it is given to Jace, which will triger, around it,
the +before+ and +after+ handlers
Installation
- Install it
gem install jace
- Or add Sinclair to your
Gemfile
andbundle install
:
gem 'jace'
bundle install jace
Using
Initialize a registry, register event handlers nad trigger events
class SomeContext
def do_something(instant)
puts "doing something #{instant}"
end
end
registry = Jace::Registry.new
context = SomeContext.new
registry.register(:the_event) { do_something(:after) }
registry.register(:the_event, :before) { do_something(:before) }
registry.trigger(:the_event, context) do
context.do_something(:middle)
end
# puts 'doing something before',
# puts 'doing something middle',
# puts 'doing something after'