A
Alexey Petrushin
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.newtext => "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!
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.newtext => "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!