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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:14:42+00:00 2026-05-24T00:14:42+00:00

Trying to inject my own function (say check) to Float class. When I am

  • 0

Trying to inject my own function (say check) to Float class. When I am doing from a module it is not injected to Float class. Please see the following snippets.

irb(main):001:0> module QA
irb(main):002:1>   class Float
irb(main):003:2>     def self.check
irb(main):004:3>     end
irb(main):005:2>   end
irb(main):006:1> end
=> nil
irb(main):007:0> include QA
=> Object
irb(main):008:0> Float.respond_to?(:check)
=> false
irb(main):009:0> extend QA
=> main
irb(main):010:0> Float.respond_to?(:check)
=> false
irb(main):011:0> class Float
irb(main):012:1>   def self.check
irb(main):013:2>   end
irb(main):014:1> end
=> nil
irb(main):015:0> Float.respond_to?(:check)
=> true
  • 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-24T00:14:43+00:00Added an answer on May 24, 2026 at 12:14 am

    This:

    module QA
      class Float
        def self.check
        end
      end
    end
    

    Is creating/modifying the class QA::Float, not Float. Try doing

    QA::Float.respond_to?(:check)
    

    And you’ll see.

    You could do something like this instead:

    module QA
        def self.included(klass)
            Float.class_eval "def self.check;end"
        end
    end
    
    include QA
    Float.respond_to?(:check)
    # true
    

    Some useful references:

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

Sidebar

Related Questions

i'm trying to inject stuff into a custom ViewPage (ModelViewPage, from MvcContrib) public class
I met a problem when trying @Singleton of Guice: import com.google.inject.Singleton; @Singleton public class
I'm trying to inject a portletrequest in my aspect class @Autowired(required = true) private
I am trying to inject entity manager in some helper class, I can pass
I have a class that uses a method from a bean. I'm trying to
I'm trying to inject EntityManager in my DAO using EJB @Entity public class Book
I am trying to inject cache to a module using module.config.php with no luck.
I'm trying to inject a dynamic where clause in my Linq to SQL query
Hi i am trying to inject a dictionary of interfaces but am getting an
I am trying to inject inside repeaters items, the problem is that the row

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.