File: //usr/local/rvm/gems/default/doc/activesupport-6.1.4.1/ri/Module/delegate_missing_to-i.ri
U:RDoc::AnyMethod[iI"delegate_missing_to:ETI"Module#delegate_missing_to;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I";When building decorators, a common pattern may emerge:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"class Partition
;TI" def initialize(event)
;TI" @event = event
;TI" end
;TI"
;TI" def person
;TI"" detail.person || creator
;TI" end
;TI"
;TI" private
;TI"@ def respond_to_missing?(name, include_private = false)
;TI"5 @event.respond_to?(name, include_private)
;TI"
end
;TI"
;TI"3 def method_missing(method, *args, &block)
;TI". @event.send(method, *args, &block)
;TI"
end
;TI" end
;T:@format0o;
; [I"IWith <tt>Module#delegate_missing_to</tt>, the above is condensed to:;T@o;; [I"class Partition
;TI"# delegate_missing_to :@event
;TI"
;TI" def initialize(event)
;TI" @event = event
;TI" end
;TI"
;TI" def person
;TI"" detail.person || creator
;TI" end
;TI" end
;T;
0o;
; [I"JThe target can be anything callable within the object, e.g. instance ;TI"(variables, methods, constants, etc.;T@o;
; [I"JThe delegated method must be public on the target, otherwise it will ;TI"Craise +DelegationError+. If you wish to instead return +nil+, ;TI"(use the <tt>:allow_nil</tt> option.;T@o;
; [ I"JThe <tt>marshal_dump</tt> and <tt>_dump</tt> methods are exempt from ;TI":delegation due to possible interference when calling ;TI"H<tt>Marshal.dump(object)</tt>, should the delegation target method ;TI"9of <tt>object</tt> add or remove instance variables.;T:
@fileI"5lib/active_support/core_ext/module/delegation.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(target, allow_nil: nil);T@BFI"Module;TcRDoc::NormalClass00