Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module RJ
- module Utils
- module NullListener
- # allows for injection of a different class for null_listeners
- #
- attr_writer :null_listener_class
- private
- # make available a null_listener that uses the null object pattern
- #
- def null_listener
- _null_listener_source.call
- end
- # creates an anonymous class based on Naught library for null listener
- # - allows for dependency injection to enable swap out of class
- #
- def _null_listener_class
- @null_listener_class ||= Naught.build
- end
- # proc which when called instantiates an instance of null listener class
- #
- def _null_listener_source
- _null_listener_class.public_method(:new)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment