Module: Hatolence::HttpClient
- Included in:
- Bias, BiasCategory, Offense, OffenseCategory, VictimCount
- Defined in:
- lib/hatolence/http_client.rb
Instance Method Summary collapse
- #build_request(params) ⇒ Object
- #get_resource(params = nil) ⇒ Object
- #resource ⇒ Object
- #root_url ⇒ Object
Instance Method Details
#build_request(params) ⇒ Object
8 9 10 |
# File 'lib/hatolence/http_client.rb', line 8 def build_request params params ? "#{root_url}?#{params}" : root_url end |
#get_resource(params = nil) ⇒ Object
4 5 6 |
# File 'lib/hatolence/http_client.rb', line 4 def get_resource params=nil result = RestClient.get build_request(params) end |
#resource ⇒ Object
16 17 18 |
# File 'lib/hatolence/http_client.rb', line 16 def resource self.class.to_s.demodulize.underscore.pluralize end |
#root_url ⇒ Object
12 13 14 |
# File 'lib/hatolence/http_client.rb', line 12 def root_url "http://hate-crimes.herokuapp.com/api/#{resource}.json" end |