lib/octogate/events.rb in octogate-0.1.0 vs lib/octogate/events.rb in octogate-0.2.0

- old
+ new

@@ -1,7 +1,22 @@ +require "active_support/core_ext/hash" module Octogate module Event + autoload :Push , "octogate/events/push" + autoload :PullRequest , "octogate/events/pull_request" + + class << self + def register_event(name, klass) + @events ||= {}.with_indifferent_access + @events[name] = klass + end + + def get(name) + @events.fetch(name) do + raise NotRegisteredEvent.new(name) + end + end + end end -end -require "octogate/events/base" -require "octogate/events/push" + class NotRegisteredEvent < StandardError; end +end