diff --git a/lib/deprecated/line/bot/client.rb b/lib/deprecated/line/bot/client.rb index c840867f..3b9941e4 100644 --- a/lib/deprecated/line/bot/client.rb +++ b/lib/deprecated/line/bot/client.rb @@ -1354,12 +1354,10 @@ def parse_events_from(request_body) json = JSON.parse(request_body) json['events'].map do |item| - begin - klass = Event.const_get(Util.camelize(item['type'])) - klass.new(item) - rescue NameError - Event::Base.new(item) - end + klass = Event.const_get(Util.camelize(item['type'])) + klass.new(item) + rescue NameError + Event::Base.new(item) end end diff --git a/lib/deprecated/line/bot/deprecate.rb b/lib/deprecated/line/bot/deprecate.rb index c0dc47c6..7871316b 100644 --- a/lib/deprecated/line/bot/deprecate.rb +++ b/lib/deprecated/line/bot/deprecate.rb @@ -12,19 +12,23 @@ # License for the specific language governing permissions and limitations # under the License. -module Line::Bot::Deprecate - def deprecate(name, replacement = nil) - class_eval do - deprecated_name = "_deprecated_#{name}" - alias_method deprecated_name, name - define_method name do |*args, &block| - message = "NOTE: #{self.class}##{name} is deprecated" - message += "; use #{replacement} instead" if replacement - message += "." - warn message - send deprecated_name, *args, &block +module Line + module Bot + module Deprecated + def deprecate(name, replacement = nil) + class_eval do + deprecated_name = "_deprecated_#{name}" + alias_method deprecated_name, name + define_method name do |*args, &block| + message = "NOTE: #{self.class}##{name} is deprecated" + message += "; use #{replacement} instead" if replacement + message += "." + warn message + send deprecated_name, *args, &block + end + ruby2_keywords name if respond_to?(:ruby2_keywords, true) + end end - ruby2_keywords name if respond_to?(:ruby2_keywords, true) end end end