Module: RestCore

Included in:
Builder, Client, ClientOauth1, EventSource, Middleware, Payload, Promise, ThreadPool, Wrapper
Defined in:
lib/rest-core.rb,
lib/rest-core/error.rb,
lib/rest-core/event.rb,
lib/rest-core/version.rb,
lib/rest-core/util/hmac.rb,
lib/rest-core/util/json.rb,
lib/rest-core/util/payload.rb,
lib/rest-core/client/universal.rb,
lib/rest-core/util/parse_query.rb,
lib/rest-core/middleware/bypass.rb

Defined Under Namespace

Modules: Client, ClientOauth1, Hmac, Json, Middleware, ParseQuery, Wrapper Classes: AuthBasic, Builder, Bypass, Cache, CommonLogger, DefaultHeaders, DefaultPayload, DefaultQuery, DefaultSite, Defaults, Dry, Engine, Error, ErrorDetector, ErrorDetectorHttp, ErrorHandler, Event, EventSource, EventStruct, FollowRedirect, HttpClient, JsonRequest, JsonResponse, NetHttpPersistent, Oauth1Header, Oauth2Header, Oauth2Query, Payload, Promise, RestClient, ThreadPool, Timeout, Timer

Constant Summary collapse

REQUEST_METHOD =
'REQUEST_METHOD'
REQUEST_PATH =
'REQUEST_PATH'
REQUEST_QUERY =
'REQUEST_QUERY'
REQUEST_PAYLOAD =
'REQUEST_PAYLOAD'
REQUEST_HEADERS =
'REQUEST_HEADERS'
RESPONSE_BODY =
'RESPONSE_BODY'
RESPONSE_STATUS =
'RESPONSE_STATUS'
RESPONSE_HEADERS =
'RESPONSE_HEADERS'
RESPONSE_SOCKET =
'RESPONSE_SOCKET'
DRY =
'core.dry'
FAIL =
'core.fail'
LOG =
'core.log'
CLIENT =
'core.client'
ASYNC =
'async.callback'
TIMER =
'async.timer'
PROMISE =
'async.promise'
HIJACK =
'async.hijack'
VERSION =
'3.0.0'
Simple =
RestCore::Builder.client
Universal =
Builder.client do
  use Timeout       , 0

  use DefaultSite   , nil
  use DefaultHeaders, {}
  use DefaultQuery  , {}
  use DefaultPayload, {}
  use JsonRequest   , false
  use AuthBasic     , nil, nil

  use FollowRedirect, 10
  use CommonLogger  , method(:puts)
  use Cache         ,  {}, 600 do
    use ErrorHandler, nil
    use ErrorDetectorHttp
    use JsonResponse, false
  end
end

Class Method Summary collapse

Class Method Details

.eagerload(const = self, loaded = {}) ⇒ Object

You might want to call this before launching your application in a threaded environment to avoid thread-safety issue in autoload.



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/rest-core.rb', line 77

def self.eagerload const=self, loaded={}
  return if loaded[const.name]
  loaded[const.name] = true
  const.constants(false).each{ |n|
    begin
      c = const.const_get(n)
    rescue LoadError, NameError => e
      warn "RestCore: WARN: #{e} for #{const}\n" \
           "  from #{e.backtrace.grep(/top.+required/).first}"
    end
    eagerload(c, loaded) if c.respond_to?(:constants) && !loaded[n]
  }
end

.idObject

identity function



92
93
94
# File 'lib/rest-core.rb', line 92

def self.id
  @id ||= lambda{ |a| a }
end