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/documented_param.rb,
lib/api_canon/documented_action.rb,
lib/api_canon/documentation_store.rb,
app/controllers/api_canon_controller.rb,
app/helpers/api_canon/api_canon_view_helper.rb

Defined Under Namespace

Modules: ApiCanonViewHelper, ClassMethods, Routes Classes: ApiCanonController, Document, DocumentationStore, DocumentedAction, DocumentedParam

Constant Summary collapse

VERSION =
'0.3.2'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/api_canon.rb', line 11

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



20
21
22
23
24
25
# File 'lib/api_canon.rb', line 20

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.



30
31
32
33
34
35
36
# File 'lib/api_canon.rb', line 30

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