class Qdocs::Base::Method
Public Class Methods
new(original_input)
click to toggle source
# File lib/qdocs.rb, line 126 def initialize(original_input) @original_input = original_input end
Public Instance Methods
index(const, pattern) { |constant| ... }
click to toggle source
# File lib/qdocs.rb, line 130 def index(const, pattern) constant = find_constant const yield constant if block_given? render_response(constant, :methods, { constant: constant, singleton_methods: own_methods(constant.methods.grep(pattern)).sort, instance_methods: own_methods(constant.instance_methods.grep(pattern)).sort, }) end
show(const, meth, type) { |constant| ... }
click to toggle source
# File lib/qdocs.rb, line 142 def show(const, meth, type) constant = find_constant(const) yield constant if block_given? method = case meth when Symbol, String method_method = case type when :instance :instance_method when :singleton, :class :method else raise UnknownMethodTypeError, "Unknown method type #{type}" end begin constant.send method_method, meth rescue NameError raise UnknownMethodError, "No method #{meth.inspect} for #{constant}. Did you mean #{constant}/#{meth}/ ?" end when ::Method, UnboundMethod meth else raise InvalidArgumentError, "#{meth.inspect} must be of type Symbol, String, or Method" end parameters = params_to_hash(method.parameters) src = method.source rescue nil source = if src lines = src.lines first_line = lines.first indent_amount = first_line.length - first_line.sub(/^\s*/, "").length lines.map { |l| l[indent_amount..-1] }.join end sup = method.super_method render_response(constant, method_method, { defined_at: source_location_to_str(method.source_location), source: source, arity: method.arity, parameters: parameters, comment: (method.comment.strip rescue nil), name: method.name, belongs_to: method.owner, super_method: sup ? Handler::Method.new(@original_input).show(sup.owner, sup, type) : nil, }) end