Method: MethodExtensions::MethodSourceWithDoc#source_with_doc

Defined in:
lib/method_extensions/method/source_with_doc.rb

#source_with_docObject

ruby-1.9.2-head > irb_context.inspect_mode = false # turn off inspect mode so that we can view sources

ruby-1.9.2-head > ActiveRecord::Base.method(:find).source_with_doc ArgumentError: failed to find method definition around the lines:

delegate :find, :first, :last, :all, :destroy, :destroy_all, :exists?, :delete, :delete_all, :update, :update_all, :to => :scoped
delegate :find_each, :find_in_batches, :to => :scoped

ruby-1.9.2-head > ActiveRecord::Base.method(:scoped).source_with_doc

# Returns an anonymous scope.
#
#   posts = Post.scoped
#   posts.size # Fires "select count(*) from  posts" and returns the count
#   posts.each {|p| puts p.name } # Fires "select * from posts" and loads post objects
#
#   fruits = Fruit.scoped
#   fruits = fruits.where(:colour => 'red') if options[:red_only]
#   fruits = fruits.limit(10) if limited?
#
# Anonymous \scopes tend to be useful when procedurally generating complex queries, where passing
# intermediate values (scopes) around as first-class objects is convenient.
#
# You can define a scope that applies to all finders using ActiveRecord::Base.default_scope.
def scoped(options = {}, &block)
  if options.present?
    relation = scoped.apply_finder_options(options)
    block_given? ? relation.extending(Module.new(&block)) : relation
  else
    current_scoped_methods ? unscoped.merge(current_scoped_methods) : unscoped.clone
  end
end

ruby-1.9.2-head > ActiveRecord::Base.method(:unscoped).source_with_doc
 => def unscoped
  @unscoped ||= Relation.new(self, arel_table)
  finder_needs_type_condition? ? @unscoped.where(type_condition) : @unscoped
end

ruby-1.9.2-head > ActiveRecord::Relation.instance_method(:find).source_with_doc
 => # Find operates with four different retrieval approaches:
...
def find(*args, &block)
  return to_a.find(&block) if block_given?

  options = args.extract_options!

  if options.present?
...


104
105
106
107
108
# File 'lib/method_extensions/method/source_with_doc.rb', line 104

def source_with_doc
  return unless source_location

  [doc.to_s.chomp, source_unindent(source)].compact.reject(&:empty?).join("\n")
end