module ApipieDSL::Method
Public Instance Methods
aliases(*names)
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 173 def aliases(*names) dsl_data[:aliases] = names end
example(example, desc_or_options = nil, options = {})
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 231 def example(example, desc_or_options = nil, options = {}) if desc_or_options.is_a?(Hash) options.merge!(desc_or_options) elsif !desc_or_options.nil? options[:desc] = desc_or_options end dsl_data[:examples] << { example: example, desc: options[:desc], for: options[:for] } end
example_for(method_name, example, desc_or_options = nil, options = {})
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 240 def example_for(method_name, example, desc_or_options = nil, options = {}) if desc_or_options.is_a?(Hash) options.merge!(desc_or_options) elsif !desc_or_options.nil? options[:desc] = desc_or_options end dsl_data[:examples] << { example: example, desc: options[:desc], for: method_name } end
method(name, desc = nil, _options = {})
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 168 def method(name, desc = nil, _options = {}) dsl_data[:name] = name dsl_data[:short_description] = desc end
raises(error_or_options, desc = nil, options = {})
click to toggle source
Describe possible errors
Example:
raises :desc => "wrong argument", :error => ArgumentError, :meta => [:some, :more, :data] raises ArgumentError, "wrong argument" def print_string(string) raise ArgumentError unless string.is_a?(String) puts string end
# File lib/apipie_dsl/dsl.rb, line 191 def raises(error_or_options, desc = nil, options = {}) dsl_data[:raises] << [error_or_options, desc, options] end
returns(retobj_or_options, desc_or_options = nil, options = {}, &block)
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 195 def returns(retobj_or_options, desc_or_options = nil, options = {}, &block) raise MultipleReturnsError unless dsl_data[:returns].nil? if desc_or_options.is_a?(Hash) options.merge!(desc_or_options) elsif !desc_or_options.nil? options[:desc] = desc_or_options end if retobj_or_options.is_a?(Hash) options.merge!(retobj_or_options) elsif retobj_or_options.is_a?(Symbol) options[:param_group] = retobj_or_options else options[:object_of] ||= retobj_or_options end options[:scope] ||= default_param_group_scope raise ArgumentError, 'Block can be specified for Hash return type only' if block && (options[:object_of] != Hash) data = [options, block] dsl_data[:returns] = data unless options[:property] data end
see(method, options = {})
click to toggle source
Reference other similar method
method :print see "MyIO#puts" def print; end
# File lib/apipie_dsl/dsl.rb, line 226 def see(method, options = {}) args = [method, options] dsl_data[:see] << args end
signature(*signature)
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 177 def signature(*signature) dsl_data[:signature] = signature end