Skip to content

Commit b656549

Browse files
committed
Quit top level reference
Referencing from within a gem like `Line::Bot::XXXX`, it is difficult to rename and use the module.
1 parent 5cc3197 commit b656549

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

lib/line/bot/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module API
2222

2323
DEFAULT_HEADERS = {
2424
'Content-Type' => 'application/json; charset=UTF-8',
25-
'User-Agent' => "LINE-BotSDK-Ruby/#{Line::Bot::API::VERSION}"
25+
'User-Agent' => "LINE-BotSDK-Ruby/#{VERSION}"
2626
}.freeze
2727
end
2828
end

lib/line/bot/client.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ def initialize(options = {})
4848
end
4949

5050
def httpclient
51-
@httpclient ||= Line::Bot::HTTPClient.new(http_options)
51+
@httpclient ||= HTTPClient.new(http_options)
5252
end
5353

5454
def endpoint
55-
@endpoint ||= Line::Bot::API::DEFAULT_ENDPOINT
55+
@endpoint ||= API::DEFAULT_ENDPOINT
5656
end
5757

5858
def blob_endpoint
5959
return @blob_endpoint if @blob_endpoint
6060

61-
@blob_endpoint = if endpoint == Line::Bot::API::DEFAULT_ENDPOINT
62-
Line::Bot::API::DEFAULT_BLOB_ENDPOINT
61+
@blob_endpoint = if endpoint == API::DEFAULT_ENDPOINT
62+
API::DEFAULT_BLOB_ENDPOINT
6363
else
6464
# for backward compatible
6565
endpoint
@@ -605,7 +605,7 @@ def get_friend_demographics
605605
#
606606
# @return [Net::HTTPResponse]
607607
def get(endpoint_base, endpoint_path, headers = {})
608-
headers = Line::Bot::API::DEFAULT_HEADERS.merge(headers)
608+
headers = API::DEFAULT_HEADERS.merge(headers)
609609
httpclient.get(endpoint_base + endpoint_path, headers)
610610
end
611611

@@ -618,7 +618,7 @@ def get(endpoint_base, endpoint_path, headers = {})
618618
#
619619
# @return [Net::HTTPResponse]
620620
def post(endpoint_base, endpoint_path, payload = nil, headers = {})
621-
headers = Line::Bot::API::DEFAULT_HEADERS.merge(headers)
621+
headers = API::DEFAULT_HEADERS.merge(headers)
622622
httpclient.post(endpoint_base + endpoint_path, payload, headers)
623623
end
624624

@@ -630,7 +630,7 @@ def post(endpoint_base, endpoint_path, payload = nil, headers = {})
630630
#
631631
# @return [Net::HTTPResponse]
632632
def delete(endpoint_base, endpoint_path, headers = {})
633-
headers = Line::Bot::API::DEFAULT_HEADERS.merge(headers)
633+
headers = API::DEFAULT_HEADERS.merge(headers)
634634
httpclient.delete(endpoint_base + endpoint_path, headers)
635635
end
636636

@@ -644,10 +644,10 @@ def parse_events_from(request_body)
644644

645645
json['events'].map do |item|
646646
begin
647-
klass = Line::Bot::Event.const_get(Line::Bot::Util.camelize(item['type']))
647+
klass = Event.const_get(Util.camelize(item['type']))
648648
klass.new(item)
649649
rescue NameError
650-
Line::Bot::Event::Base.new(item)
650+
Event::Base.new(item)
651651
end
652652
end
653653
end

lib/line/bot/event/message.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ module MessageType
3131
# https://developers.line.biz/en/reference/messaging-api/#message-event
3232
class Message < Base
3333
def type
34-
Line::Bot::Event::MessageType.const_get(@src['message']['type'].capitalize)
34+
MessageType.const_get(@src['message']['type'].capitalize)
3535
rescue NameError => e
36-
Line::Bot::Event::MessageType::Unsupport
36+
MessageType::Unsupport
3737
end
3838

3939
def message

lib/line/bot/event/things.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ module ThingsType
2929
# * https://developers.line.biz/en/reference/messaging-api/#scenario-result-event
3030
class Things < Base
3131
def type
32-
Line::Bot::Event::ThingsType.const_get(Line::Bot::Util.camelize(@src['things']['type']))
32+
ThingsType.const_get(Util.camelize(@src['things']['type']))
3333
rescue NameError
34-
Line::Bot::Event::ThingsType::Unsupport
34+
ThingsType::Unsupport
3535
end
3636

3737
def device_id

0 commit comments

Comments
 (0)