lib/errawr.rb in errawr-1.1.1 vs lib/errawr.rb in errawr-1.1.2

- old
+ new

@@ -6,16 +6,23 @@ module Errawr I18n.load_path += Dir.glob('lib/errawr/locales/*.{rb,yml}') I18n.reload! - def self.error!(name, context = {}) - klass = Mapper[name] || Mapper[:unknown] - klass.metadata.merge!(context.delete(:metadata) || {}) - klass.context.merge!(context) - raise klass + def self.included(base) + base.extend(ClassMethods) end - def self.register!(key, options = {}) - Mapper.register!(key, options) + module ClassMethods + def error!(name, context = {}) + klass = Mapper[name] || Mapper[:unknown] + klass.metadata.merge!(context.delete(:metadata) || {}) + klass.context.merge!(context) + raise klass + end + + def register!(key, options = {}) + Mapper.register!(key, options) + end end + extend ClassMethods end