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 8898785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:41:57+00:00 2026-06-15T00:41:57+00:00

I have a base class in Ruby that has a class method which it

  • 0

I have a base class in Ruby that has a class method which it has inherited. I would like to call this method in the base class, but pass it an option which is specified by the derived class, like so:

class Base < SuperDuperClass
  super_duper_class_method :option => my_option_value

  def self.my_option_value
    raise "Method my_option_value must be overridden by all subclasses"
  end
end

class Derived < Base
  def self.my_option_value
    "My Derived Option Value"
  end
end

However, this isn’t working. I believe it’s because the top-level code in the base class is executed before the top-level code in the derived class, so the derived method is not defined when super_duper_class_method is called. I’d rather not have to call super_duper_class_method in all the derived classes, but just specify the option instead.

Any ideas?

  • 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-06-15T00:41:58+00:00Added an answer on June 15, 2026 at 12:41 am

    Just to close this off, my solution is to call super_duper_class_method in the subclasses. This is what I was trying to avoid, but in this situation, I don’t think it’s possible to get what I was going for without some pretty wild metaprogramming.

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

Sidebar

Related Questions

I have a ruby view that has this namespace: ActionView::Base.new but i want to
We have a model association that looks something like this: class Example < ActiveRecord::Base
I have a base class like this: public class BaseResponse { public string ErrorMessage
I have something like this: class Person < ActiveRecord::Base has_many :things do def [](kind)
I have a base class ( car ) and a class that inherit the
I have a Ruby on Rails project that has been untouched for a while,
I have a Model called statistics which has a value field that contains Goals
I have a class that has a constructor. The constructor passes a param to
I have a parent class called Exam and that has many instances of a
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC

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.