Global 'include <Some_Module>' conflicts with OpenStruct

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’

Thanks!

On Sep 12, 2008, at 02:37 , Alexey P. wrote:

def text; puts “The ‘text’ method from the ‘A’ module.” end
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.