Sha256: fc8d4188dcfe3199ec33b6fc02a51326ac46b55b03f21de1d2b3a056ee1a694a

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require "restapi/helpers"
require "restapi/application"
require "ostruct"
require "erb"

module Restapi
  extend Restapi::Helpers

  def self.app
    @application ||= Restapi::Application.new
  end
  
  def self.to_json(resource_name = nil, method_name = nil)
    app.to_json(resource_name, method_name)
  end

  # all calls delegated to Restapi::Application instance
  def self.method_missing(method, *args, &block)
    app.respond_to?(method) ? app.send(method, *args, &block) : super
  end

  def self.configure
    yield configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  class Configuration
    attr_accessor :app_name, :app_info, :copyright, :markup_language, :validate, :api_base_url, :doc_base_url

    def app_info=(text)
      @app_info = Restapi.rdoc.convert(text.strip_heredoc)
    end
    
    def initialize
      @markup_language = :rdoc
      @app_name = "Another API"
      @app_info = "Another API description"
      @copyright = nil
      @validate = true
      @api_base_url = ""
      @doc_base_url = "/restapi"
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restapi-0.0.2 lib/restapi/restapi_module.rb