Class: SabreDevStudio::RequestObject

Inherits:
Hash
  • Object
show all
Defined in:
lib/sabre_dev_studio/request_object.rb

Overview

Base RequestObject that other API objects can inherit from

Example:

module SabreDevStudio
  module Flight
    class TravelThemeLookup < SabreDevStudio::RequestObject
    end
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, options = {}) ⇒ RequestObject

Returns a new instance of RequestObject.



18
19
20
# File 'lib/sabre_dev_studio/request_object.rb', line 18

def initialize(endpoint, options = {})
  @response = SabreDevStudio::Base.get(endpoint, :query => options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



22
23
24
25
26
27
28
# File 'lib/sabre_dev_studio/request_object.rb', line 22

def method_missing(meth, *args, &block)
  if hashie.respond_to?(meth)
    hashie.send(meth)
  else
    super
  end
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



16
17
18
# File 'lib/sabre_dev_studio/request_object.rb', line 16

def response
  @response
end

Instance Method Details

#respond_to?(meth) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/sabre_dev_studio/request_object.rb', line 30

def respond_to?(meth)
  if hashie.respond_to?(meth)
    true
  else
    super
  end
end