class Endpointer::AppCreator

Public Instance Methods

create(config) click to toggle source
# File lib/endpointer/app_creator.rb, line 8
def create(config)
  resources(config).each do |resource|
    app.send(resource.method, path(resource.url)) do
      executor_response = Endpointer::ResourceExecutor.new.perform(request, resource, config)
      headers executor_response.headers
      executor_response.body
    end
  end
  app
end

Private Instance Methods

app() click to toggle source
# File lib/endpointer/app_creator.rb, line 21
def app
  @app ||= Sinatra.new(Endpointer::App)
end
path(url) click to toggle source
# File lib/endpointer/app_creator.rb, line 25
def path(url)
  URI.parse(url).path
end
resources(config) click to toggle source
# File lib/endpointer/app_creator.rb, line 29
def resources(config)
  Endpointer::ResourceParser.new.parse(config.resource_config)
end