Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6537577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:37:58+00:00 2026-05-25T10:37:58+00:00

class Class def mixin_ancestors(include_ancestors=true) ancestors.take_while {|a| include_ancestors || a != superclass }. select {|ancestor|

  • 0
class Class
  def mixin_ancestors(include_ancestors=true)
    ancestors.take_while {|a| include_ancestors || a != superclass }.
    select {|ancestor| ancestor.instance_of?(Module) }
  end
end

class MyTestClass

end

Took the above code from How do you list included Modules in a Ruby Class?

I have following questions.

1) By saying ‘def mixin_ancestors’ as in the above code we are defining an instance method. But doing ‘a = MyTestClass.new ; a.mixin_ancestors’ says undefined method mixin_ancestors.

2) So I did ‘MyTestClass. mixin_ancestors’. It gave me a list .

3) I think ‘ancestors’ is a method. In which context does the ‘ancestors’ method runs. To find that I did ‘method(ancestors).owner’ but got error- method: [MyTestClass, Object, Kernel, BasicObject] is not a symbol (TypeError). Got this trick from my own previous question Determine the class to which a method belongs in rails

4) Like third point on which context does superclass method in the above code runs.

Thanks for the helps

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:37:59+00:00Added an answer on May 25, 2026 at 10:37 am

    1 & 2) We are defining an instance method of Class which means it will be a class method for other objects.

    3) It is run within Class object, so it is a method of Class or one of it’s ancestors (it’s actually in BasicObject)

    4) It is run in context of Class object (or of object extending it)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class Foo def initialize(a) puts Hello #{a} end end module Bar def initialize(b) puts
class A def initialize @x = do_something end def do_something 42 end end How
class A def a puts 'in #a' end end class B < A def
class Observer def initialize(&block) instance_eval(&block) if block_given? end end I'm wondering what assumption is
I have code: class Scene def initialize(number) @number = number end attr_reader :number end
Here is some code: class Person def initialize(age) @age = age end def age
I have class Fruit < ActiveRecord::Base includes Skin end and the mixin module module
Here's what I have: module EventDependencyProperties def start_date shows.order('show_date ASC').first.show_date end def end_date shows.order('show_date
I have a method which calls for a classmethod of another class def get_interface_params_by_mac(self,
class MyWriter: def __init__(self, stdout): self.stdout = stdout self.dumps = [] def write(self, text):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.