Posted about 4 years ago. Visible to the public.

Delegating an instance method to a class method in Ruby

With ActiveSupport you can say:

class Robot def self.likes_humans? 'Nope.' end delegate :likes_humans?, to: :class end Robot.likes_humans? # => 'Nope.' # => 'Nope.'
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Thomas Klemm
Last edit:
about 4 years ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Thomas Klemm to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more