Module: Remotely

Defined in:
lib/remotely.rb,
lib/remotely/model.rb,
lib/remotely/version.rb,
lib/remotely/collection.rb,
lib/remotely/application.rb,
lib/remotely/associations.rb,
lib/remotely/http_methods.rb

Defined Under Namespace

Modules: Associations, HTTPMethods Classes: Application, Collection, HasManyForeignKeyError, Model, NonJsonResponseError, RemoteAppError, RemotelyError, URLHostError

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.app(name, url = nil, &block) ⇒ Object

Register an application with Remotely.

Parameters:

  • name (Symbol)

    Placeholder name for the application.

  • url (String) (defaults to: nil)

    URL to the application’s API.

  • Block (Block)

    defining the attributes of the application.



68
69
70
71
72
73
74
# File 'lib/remotely.rb', line 68

def app(name, url=nil, &block)
  if !url && block_given?
    apps[name] = Application.new(name, &block)
  else
    apps[name] = Application.new(name) { url(url) }
  end
end

.appsHash

Returns Registered application configurations.

Returns:

  • (Hash)

    Registered application configurations



44
45
46
# File 'lib/remotely.rb', line 44

def apps
  @apps ||= {}
end

.configure(&block) ⇒ Object

Configure applications to be used by models. Accepts a block which specifies multiple apps via the ‘app` method.

Examples:

Registers an app named :fun with a URL of “fun.com/api/”

Remotely.configure do
  app :fun, "http://fun.com/api/"
end

Parameters:

  • block (Proc)

    Configuration block.



58
59
60
# File 'lib/remotely.rb', line 58

def configure(&block)
  instance_eval(&block)
end

.reset!Object

Clear all registered apps



78
79
80
# File 'lib/remotely.rb', line 78

def reset!
  @apps = {}
end