Sha256: 384f101ceb3075a9506d2c1c3ba9a1b383752dbe926a7defce323befddd738ed

Contents?: true

Size: 986 Bytes

Versions: 2

Compression:

Stored size: 986 Bytes

Contents

module Eleyo
  module API
    class << self
      @@mode = :standard
      [:test, :dev, :standard].each do |m|
        define_method("#{m}mode?") do
          @@mode == m
        end
        
        define_method("#{m}mode") do
          @@mode == m
        end
        
        define_method("#{m}mode=") do |b|
          @@mode = b ? m : :standard
        end
      end
    end
    
    class Error < StandardError
      attr_accessor :http_status_code
      def initialize(code, message)
        self.http_status_code = code.to_i
        begin
          self.json = JSON.parse(message)
        rescue
        end
        
        super "(#{code}) #{message}"
      end
    end
    
    class InitializerError < StandardError
      def initialize(method, message)        
        super "#{method} #{message}"
      end
    end

    class RequirementError < StandardError
      def initialize(method, message)        
        super "#{method} #{message}"
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eleyo-1.2.1 lib/eleyo/api.rb
eleyo-1.2.0 lib/eleyo/api.rb