lib/boty/slack/url.rb in boty-0.1.0 vs lib/boty/slack/url.rb in boty-0.1.1
- old
+ new
@@ -1,12 +1,17 @@
module Boty
module Slack
module URL
def self.included(base)
+ class << base
+ attr_reader :_url
+ end
+
base.instance_eval do
- def url(url); @_url = url end
- def _url; @_url end
+ def url(url)
+ @_url = url
+ end
end
end
def self.get(url)
JSON.parse Net::HTTP.get(URI(url)) || "{}"
@@ -14,14 +19,14 @@
private
def parameterize(user_parameters, path: nil)
url = path ? self.class._url + path : self.class._url
- parameters = {token: ENV["SLACK_BOT_API_TOKEN"]}.merge user_parameters
- parameters.reduce(url + "?") { |_url, param|
+ parameters = { token: ENV["SLACK_BOT_API_TOKEN"] }.merge user_parameters
+ parameters.reduce(url + "?") { |final_url, param|
parameter = param[0]
value = URI.encode param[1].to_s
- "#{_url}#{parameter}=#{value}&"
+ "#{final_url}#{parameter}=#{value}&"
}.gsub(/&$/, "")
end
end
end
end