Class: Tortilla::ApiWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/tortilla.rb

Instance Method Summary collapse

Constructor Details

#initialize(domain) ⇒ ApiWrapper

Returns a new instance of ApiWrapper.



40
41
42
43
# File 'lib/tortilla.rb', line 40

def initialize(domain)
  @domain = domain
  @request = RequestBuilder.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/tortilla.rb', line 51

def method_missing(meth,*args,&block)
  @request.url= @domain+"/"+meth.to_s

  if(!args.first.nil? && !args.nil?)
    @request.url = @request.url+"/"+args.first
  end

  return @request
end

Instance Method Details

#def(headers) ⇒ Object



45
46
47
48
49
# File 'lib/tortilla.rb', line 45

def

def headers
  return @request.headers
end

#on_response(&block) ⇒ Object



61
62
63
# File 'lib/tortilla.rb', line 61

def on_response(&block)
  @request.response_parser = block
end