module ApipieDSL::Module
Public Instance Methods
apipie(context = :method, desc_or_options = nil, options = {}, &block)
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 457 def apipie(context = :method, desc_or_options = nil, options = {}, &block) if desc_or_options.is_a?(Hash) options = options.merge(desc_or_options) elsif desc_or_options.is_a?(String) options[:desc] = desc_or_options end options[:name] ||= context.to_s block = proc {} unless block_given? delegatee = Delegatee.instance_for(self).with(&block) delegatee.short(options[:desc]) # Don't eval the block, since it will be evaluated after method is defined return if context == :method delegatee.with(options).eval_dsl_for(context) Delegatee.instance_reset end
apipie_class(name, desc_or_options = nil, options = {}, &block)
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 439 def apipie_class(name, desc_or_options = nil, options = {}, &block) delegatee = prepare_delegatee(self, desc_or_options, options, &block) delegatee.name(name) delegatee.with(options).eval_dsl_for(:class) Delegatee.instance_reset end
apipie_method(name, desc_or_options = nil, options = {}, &block)
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 447 def apipie_method(name, desc_or_options = nil, options = {}, &block) delegatee = prepare_delegatee(self, desc_or_options, options, &block) dsl_data = delegatee.eval_dsl_for(:method) class_scope = delegatee.class_scope ApipieDSL.remove_method_description(class_scope, dsl_data[:dsl_versions], name) ApipieDSL.define_method_description(class_scope, name, dsl_data) Delegatee.instance_reset end
method_added(method_name)
click to toggle source
Calls superclass method
# File lib/apipie_dsl/dsl.rb, line 476 def method_added(method_name) super if Delegatee.instance.nil? # Don't autoload methods if validations are enabled but no apipie block # was called return if ApipieDSL.configuration.validate? # If no apipie block was called but validations are disabled then # it's possible to autoload methods return unless ApipieDSL.configuration.autoload_methods? apipie end instance = Delegatee.instance class_scope = instance.class_scope # Mainly for Rails in case of constant loading within apipie block. # Prevents methods, that are being defined in other class than the class # where apipie block was called, to be documented with current apipie block return unless class_scope == self dsl_data = instance.eval_dsl_for(:method) ApipieDSL.remove_method_description(class_scope, dsl_data[:dsl_versions], method_name) method_desc = ApipieDSL.define_method_description(class_scope, method_name, dsl_data) Delegatee.instance_reset Delegatee.define_validators(class_scope, method_desc) ensure # Reset if we finished method describing in the right class Delegatee.instance_reset if class_scope == self end
Private Instance Methods
prepare_delegatee(scope, desc_or_options, options, &block)
click to toggle source
# File lib/apipie_dsl/dsl.rb, line 510 def prepare_delegatee(scope, desc_or_options, options, &block) if desc_or_options.is_a?(Hash) options = options.merge(desc_or_options) elsif desc_or_options.is_a?(String) options[:desc] = desc_or_options end block = proc {} unless block_given? delegatee = Delegatee.instance_for(scope).with(&block) delegatee.short(options[:desc]) delegatee end