Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
zenizh committed Jul 13, 2023
1 parent 3ff010d commit 91aee3e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
10 changes: 4 additions & 6 deletions lib/deprecated/line/bot/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 16 additions & 12 deletions lib/deprecated/line/bot/deprecate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 91aee3e

Please sign in to comment.