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

  • Home
  • SEARCH
  • 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 8852179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:20:08+00:00 2026-06-14T13:20:08+00:00

I’d like to use a Ruby Module to store a set of configuration defaults.

  • 0

I’d like to use a Ruby Module to store a set of configuration defaults.

I’m having some problems using the values and hope someone could help.

This may not be the best way to do this but this is what I’ve come up with so far.

Here is a module to hold value for a persons Resume => resume.rb

module Resume
  require 'ostruct'

  attr_reader :personal, :education

  @personal = OpenStruct.new

  @education = Array.new

  def self.included(base)
    set_personal
    set_education
  end

  def self.set_personal
    @personal.name          = "Joe Blogs"
    @personal.email_address = 'joe.blogs@gmail.com'
    @personal.phone_number  = '5555 55 55 555'
  end

  def self.set_education
    @education << %w{ School\ 1 Description\ 1 }
    @education << %w{ School\ 2 Description\ 2 }
  end
end

From irb it works fine:

% irb -I .
1.9.3-p194 :001 > require 'resume'
 => true 
1.9.3-p194 :002 > include Resume
 => Object 
1.9.3-p194 :003 > puts Resume.personal.name
Joe Blogs
 => nil 

However when I include this into a class it throws and error => build.rb

require 'resume'

class Build
  include Resume

  def build
    puts Resume.personal.name
  end
end

From irb:

% irb -I .
1.9.3-p194 :001 > require 'build'
 => true 
1.9.3-p194 :002 > b = Build.new
 => #<Build:0x00000001d0ebb0> 
1.9.3-p194 :003 > b.build
NoMethodError: undefined method `personal' for Resume:Module
    from /home/oolyme/projects/lh_resume_builder_ruby/build.rb:7:in `build'
    from (irb):3
    from /home/oolyme/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'

I’ve tried a few variations to output the include module variables in the Build class instance but all error out.

  • 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-14T13:20:09+00:00Added an answer on June 14, 2026 at 1:20 pm

    attr_accessor creates a couple of instance methods, meaning that they will be available on an instance of Build. But you clearly want class instance methods. Change definition of your module to this:

    module Resume
      require 'ostruct'
    
      def self.personal
        @personal
      end
    
      def self.education
        @education
      end
    
      def self.included(base)
        @personal = OpenStruct.new
        @education = Array.new
    
        set_personal
        set_education
      end
    
      def self.set_personal
        @personal.name          = "Joe Blogs"
        @personal.email_address = 'joe.blogs@gmail.com'
        @personal.phone_number  = '5555 55 55 555'
      end
    
      def self.set_education
        @education << %w{ School\ 1 Description\ 1 }
        @education << %w{ School\ 2 Description\ 2 }
      end
    end
    

    And it’ll work

    b = Build.new
    b.build # >> Joe Blogs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words

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.