Module: RestCore

Included in:
Builder, Client, ClientOauth1, EventSource, Middleware, Payload, Promise, ThreadPool
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/clash.rb,
lib/rest-core/util/smash.rb,
lib/rest-core/util/config.rb,
lib/rest-core/util/payload.rb,
lib/rest-core/util/parse_link.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, Config, Hmac, Json, Middleware, ParseLink, ParseQuery Classes: AuthBasic, Builder, Bypass, Cache, Clash, ClashResponse, CommonLogger, DefaultHeaders, DefaultPayload, DefaultQuery, DefaultSite, Defaults, Dry, Engine, Error, ErrorDetector, ErrorDetectorHttp, ErrorHandler, Event, EventSource, EventStruct, FollowRedirect, HttpClient, JsonRequest, JsonResponse, Oauth1Header, Oauth2Header, Oauth2Query, Payload, Promise, QueryResponse, Smash, SmashResponse, 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'
REQUEST_URI =
'REQUEST_URI'
RESPONSE_BODY =
'RESPONSE_BODY'
RESPONSE_STATUS =
'RESPONSE_STATUS'
RESPONSE_HEADERS =
'RESPONSE_HEADERS'
RESPONSE_SOCKET =
'RESPONSE_SOCKET'
RESPONSE_KEY =
'RESPONSE_KEY'
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.4.1'
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 CommonLogger  , method(:puts)
  use ErrorHandler  , nil
  use ErrorDetectorHttp

  use SmashResponse , false
  use ClashResponse , false
  use  JsonResponse , false
  use QueryResponse , false

  use Cache         , {}, 600 # default :expires_in 600 but the default
                              # cache {} didn't support it

  use FollowRedirect, 10
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.



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rest-core.rb', line 83

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/u).first}"
    end
    eagerload(c, loaded) if c.respond_to?(:constants) && !loaded[n]
  }
end

.idObject

identity function



98
99
100
# File 'lib/rest-core.rb', line 98

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