Class: Genomelink::Base
- Inherits:
-
Object
- Object
- Genomelink::Base
- Defined in:
- lib/genomelink/base.rb
Overview
The Base class for all of the other class. Let other classes inherit from here and put common methods here.
Class Method Summary collapse
-
.get(path, token) ⇒ Hash
Makes a get request to genomelink for the URL given and with the given token.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Subclass os Base
constructor
A constructor to take a hash and assign it to the instance variables.
Constructor Details
#initialize(options = {}) ⇒ Subclass os Base
A constructor to take a hash and assign it to the instance variables
41 42 43 44 45 |
# File 'lib/genomelink/base.rb', line 41 def initialize( = {}) .each do |attribute, value| instance_variable_set("@#{attribute}", value) end end |
Class Method Details
.get(path, token) ⇒ Hash
Makes a get request to genomelink for the URL given and with the given token.
TODO : use meta programming and define all Restful methods.
18 19 20 21 22 23 24 |
# File 'lib/genomelink/base.rb', line 18 def get(path, token) result = service(token).get do |req| req.url path req.headers['Authorization'] = "BEARER #{token}" end JSON.parse(result.body) end |