Sha256: 058b64278cba0032e96bf237c7a3a3fc0ac45ecfcb1f5d0695f3cfc714f6bc38

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

module Spigot
  class Proxy

    ## Proxy
    #
    # Spigot::Proxy provides accessor methods used by the implementation
    # that could be useful for development or custom behavior

    attr_reader :resource, :service

    ## #initialize(resource)
    # Method to initialize a proxy.
    #
    # @param service [String] This is the service that dictates the proxy.
    # @param resource [Object] This is the class implementing the proxy.
    def initialize(service, resource)
      raise MissingServiceError, "No service definition found for #{service}" if Spigot.config.map.service(service).nil?
      @service  = service
      @resource = resource
    end

    ## #translator
    # Instantiate a Spigot::Translator object with the contextual service and resource
    def translator
      Translator.new(service, resource)
    end

    ## #map
    # Return a hash of the data map the current translator is using
    def map
      translator.resource_map
    end

    ## #options
    # Return a hash of any service specific options for this translator. `Spigot.config` not included
    def options
      translator.options || {}
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spigot-0.2.1 lib/spigot/proxy.rb
spigot-0.2.0 lib/spigot/proxy.rb