Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
Is it possible to freeze (make immutable) a class or a method in Ruby?

In Ruby:

module Example
  class ExampleValidator
    def mymethod
      # do something important
    end
  end
end

Is it possible to make mymethod immutable (i.e. no monkey patching)?

Otherwise it would also be acceptable to "freeze" the entire class ExampleValidator.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Yes, you can call freeze on a Module.

Example::ExampleVaildator.freeze

However, I'd question why this is necessary. Perhaps it is solving a social problem with a technical one. A tool such as Rubocop should warn about monkey patches.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!