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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:29:31+00:00 2026-05-15T13:29:31+00:00

I’d like a very basic example of a tiny base program, that reads in

  • 0

I’d like a very basic example of a tiny base program, that reads in two plugins and registers them. These two plugins hook into the base program in the same way in a unconflicting manner.

I’m very new to metaprogramming in any programming language for that matter, I’m not sure where to start.

  • 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-15T13:29:32+00:00Added an answer on May 15, 2026 at 1:29 pm

    i’ve been working on this very problem for a while now. i’ve tried a number of different ways to go about doing it and sought advice from a lot of people on it. i’m still not sure if what i have is ‘the right way’, but it works well and is easy to do.

    in my case, i’m specifically looking at configuration and bringing in configuration plugins, but the principle is the same even if the terminology for mine is specific to cnfiguration.

    at a very basic level, i have a Configuration class with nothing in it – it’s empty. I also have a Configure method which returns the configuration class and lets you call methods on it:

    # config.rb
    class Configuration
    end
    
    class MySystem
      def self.configure
        @config ||= Configuration.new
        yield(@config) if block_given?
        @config
      end
    
      Dir.glob("plugins/**/*.rb").each{|f| require f}
    end
    
    MySystem.configure do |config|
      config.some_method
      config.some_value = "whatever"
      config.test = "that thing"
    end
    
    puts "some value is: #{MySystem.configure.some_value}"
    puts "test #{MySystem.configure.test}"
    

    to get the some_method and some_value on the configuration class, I have the plugins extend the configuration object via modules:

    # plugins/myconfig.rb
    module MyConfiguration
      attr_accessor :some_value
    
      def some_method
        puts "do stuff, here"
      end
    end
    
    class Configuration
      include MyConfiguration
    end
    

    and

    # plugins/another.rb
    module AnotherConfiguration
      attr_accessor :test
    end
    
    class Configuration
      include AnotherConfiguration
    end
    

    to load up the plugins, you only need one of code to look for the .rb files in a specific folder and ‘require’ them. this code can live anywhere as long as it’s run right away when the file that contains it is loaded… i would probably put it in the class definition for MySystem or something like that to start with. maybe move it somewhere else when makes sense.

    Dir.glob("plugins/**/*.rb").each{|f| require f}

    run config.rb and you’ll get output that looks like this:

    do stuff, here 
    some value is: whatever
    test that thing
    

    there are a lot of options for implementing the various parts of this, but this should get you down the path.

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

Sidebar

Ask A Question

Stats

  • Questions 444k
  • Answers 444k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I agree with others that while this is something that… May 15, 2026 at 6:35 pm
  • Editorial Team
    Editorial Team added an answer Here's some rough example code. It assumes that your login… May 15, 2026 at 6:35 pm
  • Editorial Team
    Editorial Team added an answer One bad way to do this would be to split… May 15, 2026 at 6:35 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.