Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created May 19, 2012 17:47
Show Gist options
  • Select an option

  • Save practicingruby/2731677 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/2731677 to your computer and use it in GitHub Desktop.
require "forwardable"
class BigAssObject
def initialize
@sub_object_1 = Something.new
@sub_object_2 = SomethingElse.new
@sub_object_3 = SomethingEEEELSE.new
end
delegate [:a, :b, :c, :d] => :sub_object_1
delegate [:e, :f, :g, :h] => :sub_object_2
delegate [:i, :j, :k, :l] => :sub_object_3
private
attr_reader :sub_object_1, :sub_object_2, :sub_object_3
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment