class Farscape::PlatformResources::Agent

This is a simple wrapper over Farscape::Agent which provides access to the URL on the enter method. Recreating the agent is very costly. As it tries to load the plugins and these may be heavy Specially the discovery service plugin is trying to load a file from disk every single time. We need to access a variable inside farscape to reuse the agent more than once. Once Farscape has a version which let us reuse the agent we will delete this helper.

Public Class Methods

new() click to toggle source
# File lib/farscape/platform_resources.rb, line 68
def initialize
  @agent = Farscape::Agent.new
end

Public Instance Methods

discover(resource_name, template_variables) click to toggle source
# File lib/farscape/platform_resources.rb, line 77
def discover(resource_name, template_variables)
  if @agent.respond_to?(:discover)
    @agent.discover(resource_name)
  else
    @agent.enter(resource_name)
  end
end
enter(root) click to toggle source
# File lib/farscape/platform_resources.rb, line 72
def enter(root)
  @agent.instance_variable_set(:@entry_point, root)
  @agent.enter(root)
end
method_missing(name, *args, &block) click to toggle source
# File lib/farscape/platform_resources.rb, line 85
def method_missing(name, *args, &block)
  @agent.send(name, *args, &block)
end