Sha256: 737bb27f35dd0b2f680e64897cbdc696c529ddd3e7e02415356f92f785dcc16f

Contents?: true

Size: 1.75 KB

Versions: 15

Compression:

Stored size: 1.75 KB

Contents

require "apipie/helpers"
require "apipie/application"

module Apipie
  extend Apipie::Helpers

  def self.app
    @application ||= Apipie::Application.new
  end

  def self.to_json(version = nil, resource_name = nil, method_name = nil, lang = nil)
    version ||= Apipie.configuration.default_version
    app.to_json(version, resource_name, method_name, lang)
  end

  # all calls delegated to Apipie::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

  def self.debug(message)
    puts message if Apipie.configuration.debug
  end

  # get application description for given or default version
  def self.app_info(version = nil)
    if app_info_version_valid? version
      Apipie.markup_to_html(self.configuration.app_info[version])
    elsif app_info_version_valid? Apipie.configuration.default_version
      Apipie.markup_to_html(self.configuration.app_info[Apipie.configuration.default_version])
    else
      "Another API description"
    end
  end

  def self.api_base_url(version = nil)
    if api_base_url_version_valid? version
      self.configuration.api_base_url[version]
    elsif api_base_url_version_valid? Apipie.configuration.default_version
      self.configuration.api_base_url[Apipie.configuration.default_version]
    else
      "/api"
    end
  end

  def self.app_info_version_valid?(version)
    version && self.configuration.app_info.has_key?(version)
  end

  def self.api_base_url_version_valid?(version)
    version && self.configuration.api_base_url.has_key?(version)
  end

  def self.record(record)
    Apipie::Extractor.start record
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
apipie-rails-0.3.7 lib/apipie/apipie_module.rb
apipie-rails-0.3.6 lib/apipie/apipie_module.rb
apipie-rails-0.3.5 lib/apipie/apipie_module.rb
apipie-rails-0.3.4 lib/apipie/apipie_module.rb
apipie-rails-0.3.3 lib/apipie/apipie_module.rb
apipie-rails-0.3.2 lib/apipie/apipie_module.rb
apipie-rails-0.3.1 lib/apipie/apipie_module.rb
apipie-rails-0.3.0 lib/apipie/apipie_module.rb
apipie-rails-0.2.6 lib/apipie/apipie_module.rb
apipie-rails-0.2.5 lib/apipie/apipie_module.rb
apipie-rails-0.2.4 lib/apipie/apipie_module.rb
apipie-rails-0.2.3 lib/apipie/apipie_module.rb
apipie-rails-0.2.2 lib/apipie/apipie_module.rb
apipie-rails-0.2.1 lib/apipie/apipie_module.rb
apipie-rails-0.2.0 lib/apipie/apipie_module.rb