API Docs for:
Show:

Hop Class

Module: Hop

Item Index

Methods

addToJSONHandler

(
  • onJSON
  • The
)
static

Defined in lib/api.js:351

Add a call back which will be called when a version of the API must be built from JSON

Parameters:

  • onJSON Function

    Callback to be called when a json version of Hop is requested

  • The Object

    stub object which is being populated for conversion to JSON

addToJSONHandler

(
  • onJSON
  • The
)
static

Defined in lib/api.js:368

Add a call back which will be called when a JSON version of the API is requested

Parameters:

  • onJSON Function

    Callback to be called when a json version of Hop is requested

  • The Object

    stub object which is being populated for conversion to JSON

apiHook

(
  • basePath
  • app
)

Defined in lib/express.js:30

Inserts the Hop calls into express

Parameters:

  • basePath String
    the path which the Hop will hang off of
    
  • app Object
    the express app
    

call

(
  • name
  • input
  • callback
  • [request]
)
static

Defined in lib/api.js:1188

Calls the specified method

This function is provided so that all functionality around a specific call may be utilized.

Parameters:

  • name String

    Name of the function to call

  • input Object

    Input for the call

  • callback Function

    for completion

    • err

      The error returned from the call

    • result

      The result returned from the call

  • [request] Object optional

    ExpressJS/HTTP request object

Example:

var input = { username: "cfox", email:"cfox@gmail.com"}
Hop.call("UserService.create",input,function(err,res){
    Hop.log(err,res);
});

checksum

() static

Defined in lib/api.js:114

Calculate a checksum for the Hop

This is used to detect changes in the version of the Hop

defineClass

(
  • name
  • [instance]
  • onDefine
)
static

Defined in lib/api.js:248

Define a new class

  • Use #classname to have the class name substituted into the URL

Parameters:

  • name String

    the name of the class

  • [instance] Object optional

    an instance of the object

  • onDefine Function

    the lambda used to define the interface

Example:

Hop.defineClass("Email",new Email(),function(api){
    //define the class 
});

defineInterface

(
  • name
  • onDefine
)
static

Defined in lib/api.js:274

Define a new interface

  • Use #classname to have the class name substituted into the URL

Parameters:

  • name String

    the name of the interface

  • onDefine Function

    the lambda used to define the interface

Example:

Hop.defineInterface("Notification",function(api){
    api.post("send","#classname/send").usage("Sends a message").demand("msg").demand("subject").demand("to");
}

defineTestCase

(
  • name
  • lambda
)
static

Provided by the Test module.

Defined in lib/test.js:316

Define a test case for a specific method

Parameters:

  • name String

    the name of the method to test, this must be the same as a defined API method, and may also contain a commnet appened after a :

  • lambda Function

    The lambda defining the test

Example:

Hop.defineTestCase("User.authenticate: Test Authentication",function(test){
    var validUser = { email:"test@test.com", username:"TestUser" };
    test.do("User.create").with(validUser).noError();
    test.do("User.authenticate").with(validUser).noError();
    test.do("User.authenticate").with({password:"BOB"},validUser).containsError("Permission denied");
});

renderTemplate

(
  • filename
  • input
)

Defined in lib/express.js:234

Render a template using the cumbustion template engine

Parameters:

  • filename String

    The filename of the template relative to the "./static" path

  • input Object

    The inputs to the template