Ruby on Rails mini-blogs

PAGE NO LONGER MAINTAINED, all articles were moved to http://www.eq8.eu/tils where I'll continue adding more ! This page contains simple small Ruby on Rails and web-development hints that are too small for a real blog. You can visit my real blog at http://www.eq8.eu

Thursday, April 23, 2015

Use Rails (ActiveSupport) delegation class in plain ruby

# Gemfile
source "https://rubygems.org"
gem 'active_support'
require 'active_support/core_ext/module/delegation'

class Foo
  delegate :call, to: :other

  def other
    ->(){ 'foo' }
  end
end

Foo.new.call
# => 'foo'
source: http://guides.rubyonrails.org/active_support_core_extensions.html#method-delegation`
github: https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-04-23-use-rails-delegate-lib-only.md
Posted by Equivalent at 3:21 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Post Older Post Home

Blog Archive

  • ►  2016 (1)
    • ►  March (1)
  • ▼  2015 (10)
    • ►  October (1)
    • ►  August (1)
    • ►  July (1)
    • ►  June (1)
    • ▼  April (1)
      • Use Rails (ActiveSupport) delegation class in plai...
    • ►  March (3)
    • ►  February (1)
    • ►  January (1)
  • ►  2014 (9)
    • ►  December (2)
    • ►  November (1)
    • ►  October (1)
    • ►  July (1)
    • ►  May (3)
    • ►  April (1)

About Me

My photo
Equivalent
London, United Kingdom
View my complete profile
Simple theme. Powered by Blogger.