Module: Foursquare::Merchant::Errors

Defined in:
lib/foursquare/errors.rb

Defined Under Namespace

Classes: APIError, OAuthError

Class Method Summary collapse

Class Method Details

.new(type, message = nil) ⇒ Object

Dynamically create errors from responses we receive from the Foursquare Merchant API



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/foursquare/errors.rb', line 9

def self.new(type, message=nil)
  unless self.const_defined?(type)
    self.const_set type.intern, Class.new(APIError) do
      attr_reader :message

      def initialize(message=nil)
        @message = message
      end
    end
  end

  self.const_get(type).new(message)
end