From: Ryan Davis Date: 2008-09-13T04:10:53+09:00 Subject: Re: Global 'include ' conflicts with OpenStruct On Sep 12, 2008, at 02:37 , Alexey Petrushin wrote: > Hello! > > I need to include methods from module 'A' into global scope. But i > have > faced problem, it does interfere with OpenStruct. > The Code: > # ------------------------------ > require 'ostruct' > > module A > def text; puts "The 'text' method from the 'A' module." end > end > include A > > os = OpenStruct.new(:text => "Text from the 'OpenStruct'") > > puts os.text #=> The 'text' method from the 'A' module. \n nil > # ------------------------------ > How it can be solved? > > Desired behavior should be: > puts os.text #=> Text from the 'OpenStruct' OpenStruct works via method_missing... if the method isn't missing, it isn't missing... You'd probably have to add an explicit method on your os object to override the Kernel#text. Looking at the source, that appears to be what #new_ostruct_member is for.