Module: Apipie::DSL::Action
- Included in:
- Concern, Controller
- Defined in:
- lib/apipie/dsl_definition.rb
Instance Method Summary collapse
-
#api(method, path, desc = nil) ⇒ Object
Declare an api.
- #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.
Instance Method Details
#api(method, path, desc = nil) ⇒ Object
Declare an api.
Example:
api :GET, "/resource_route", "short description",
79 80 81 82 |
# File 'lib/apipie/dsl_definition.rb', line 79 def api(method, path, desc = nil) #:doc: return unless Apipie.active_dsl? _apipie_dsl_data[:api_args] << [method, path, desc] end |
#def_param_group(name, &block) ⇒ Object
70 71 72 |
# File 'lib/apipie/dsl_definition.rb', line 70 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.
96 97 98 99 |
# File 'lib/apipie/dsl_definition.rb', line 96 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, Fixnum, :desc => “User ID”, :required => true desc <<-EOS
Long description...
EOS
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/apipie/dsl_definition.rb', line 109 def resource_description( = {}, &block) #:doc: return unless Apipie.active_dsl? raise ArgumentError, "Block expected" unless block_given? dsl_data = ResourceDescriptionDsl.eval_dsl(self, &block) versions = dsl_data[:api_versions] @apipie_resource_descriptions = versions.map do |version| Apipie.define_resource_description(self, version, dsl_data) end Apipie.set_controller_versions(self, versions) end |
#see(*args) ⇒ Object
Reference other similar method
api :PUT, '/articles/:id'
see "articles#create"
def update; end
89 90 91 92 |
# File 'lib/apipie/dsl_definition.rb', line 89 def see(*args) return unless Apipie.active_dsl? _apipie_dsl_data[:see] << args end |