# Global 'include \<Some\_Module\>' conflicts with OpenStruct

**URL:** <https://www.ruby-forum.com/t/global-include-some-module-conflicts-with-openstruct/148383>\
**Category:** Ruby\
**Created:** [September 12, 2008, 11:44am UTC](https://www.ruby-forum.com/t/global-include-some-module-conflicts-with-openstruct/148383 "2008-09-12T11:44:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![axyd80](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@axyd80](https://www.ruby-forum.com/u/axyd80)\
**Post date:** [September 12, 2008, 11:44am UTC](https://www.ruby-forum.com/t/global-include-some-module-conflicts-with-openstruct/148383/1 "2008-09-12T11:44:20Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![axyd80](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@axyd80](https://www.ruby-forum.com/u/axyd80)\
**Post date:** [September 12, 2008, 9:49pm UTC](https://www.ruby-forum.com/t/global-include-some-module-conflicts-with-openstruct/148383/2 "2008-09-12T21:49:51Z")

</div>

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.
