Module: ApiCanon

Defined in:
lib/api_canon.rb,
lib/api_canon/routes.rb,
lib/api_canon/version.rb,
lib/api_canon/document.rb,
lib/api_canon/swagger/base.rb,
lib/api_canon/documented_model.rb,
lib/api_canon/documented_param.rb,
lib/api_canon/documented_action.rb,
lib/api_canon/documentation_store.rb,
app/controllers/swagger_controller.rb,
app/controllers/api_canon_controller.rb,
lib/api_canon/swagger/api_declaration.rb,
lib/api_canon/swagger/resource_listing.rb,
app/helpers/api_canon/api_canon_view_helper.rb

Defined Under Namespace

Modules: ApiCanonViewHelper, ClassMethods, Routes, Swagger Classes: ApiCanonController, Document, DocumentationStore, DocumentedAction, DocumentedModel, DocumentedParam, Engine, SwaggerController

Constant Summary collapse

VERSION =
'0.4.7'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/api_canon.rb', line 26

def self.included(base)
  base.extend(ClassMethods)
  base.class_eval do
    append_view_path File.join(File.dirname(__FILE__),'..','app','views')
    require 'helpers/api_canon/api_canon_view_helper'
    helper ApiCanon::ApiCanonViewHelper
  end
end

Instance Method Details

#api_canon_docsObject



35
36
37
38
39
40
# File 'lib/api_canon.rb', line 35

def api_canon_docs
  @api_doc = DocumentationStore.fetch controller_path
  respond_to do |format|
    format.html { render 'api_canon/api_canon', :layout => 'layouts/api_canon' }
  end
end

#indexObject

When this module is included, your index method is overwritten with this one, which renders the ApiCanon documentation if params is html, and defaults to the existing method otherwise.



45
46
47
48
49
50
51
# File 'lib/api_canon.rb', line 45

def index
  if request.format.html?
    api_canon_docs
  else
    super
  end
end