Module: Apipie::DSL::Action
- Included in:
- Concern, Controller
- Defined in:
- lib/apipie/dsl_definition.rb
Instance Method Summary collapse
-
#api(method, path, desc = nil, options = {}) ⇒ Object
# load paths from routes and don’t provide description api.
-
#api!(desc = nil, options = {}) ⇒ Object
# load paths from routes api! “short description”,.
- #def_param_group(name, &block) ⇒ Object
-
#example(example) ⇒ Object
Show some example of what does the described method return.
-
#resource_description(options = {}, &block) ⇒ Object
Describe whole resource.
-
#see(*args) ⇒ Object
Reference other similar method.
-
#show(show) ⇒ Object
Determine if the method should be included in the documentation.
Instance Method Details
#api(method, path, desc = nil, options = {}) ⇒ Object
# load paths from routes and don’t provide description
api
96 97 98 99 100 |
# File 'lib/apipie/dsl_definition.rb', line 96 def api(method, path, desc = nil, = {}) #:doc: return unless Apipie.active_dsl? _apipie_dsl_data[:api] = true _apipie_dsl_data[:api_args] << [method, path, desc, ] end |
#api!(desc = nil, options = {}) ⇒ Object
# load paths from routes
api! "short description",
105 106 107 108 109 |
# File 'lib/apipie/dsl_definition.rb', line 105 def api!(desc = nil, = {}) #:doc: return unless Apipie.active_dsl? _apipie_dsl_data[:api] = true _apipie_dsl_data[:api_from_routes] = { :desc => desc, :options => } end |
#def_param_group(name, &block) ⇒ Object
88 89 90 |
# File 'lib/apipie/dsl_definition.rb', line 88 def def_param_group(name, &block) Apipie.add_param_group(self, name, &block) end |
#example(example) ⇒ Object
Show some example of what does the described method return.
123 124 125 126 |
# File 'lib/apipie/dsl_definition.rb', line 123 def example(example) #:doc: return unless Apipie.active_dsl? _apipie_dsl_data[:examples] << example.strip_heredoc end |
#resource_description(options = {}, &block) ⇒ Object
Describe whole resource
Example: api :desc => “Show user profile”, :path => “/users/”, :version => ‘1.0 - 3.4.2012’ param :id, Integer, :desc => “User ID”, :required => true desc <<-EOS
Long description...
EOS
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/apipie/dsl_definition.rb', line 143 def resource_description( = {}, &block) #:doc: return unless Apipie.active_dsl? raise ArgumentError, "Block expected" unless block dsl_data = ResourceDescriptionDsl.eval_dsl(self, &block) versions = dsl_data[:api_versions] Apipie.set_controller_versions(self, versions) @apipie_resource_descriptions = versions.map do |version| Apipie.define_resource_description(self, version, dsl_data) end end |
#see(*args) ⇒ Object
Reference other similar method
api :PUT, '/articles/:id'
see "articles#create"
def update; end
116 117 118 119 |
# File 'lib/apipie/dsl_definition.rb', line 116 def see(*args) return unless Apipie.active_dsl? _apipie_dsl_data[:see] << args end |
#show(show) ⇒ Object
Determine if the method should be included in the documentation
130 131 132 133 |
# File 'lib/apipie/dsl_definition.rb', line 130 def show(show) return unless Apipie.active_dsl? _apipie_dsl_data[:show] = show end |