ruby - How to use prepend in a refine -
i'm trying make work following code :
require 'ostruct' module interactorsrefine module openstructprepend def delete_field(name) super(name) if self.__send__(name) end end refine openstruct prepend openstructprepend end end module testy include interactorsrefine person = openstruct.new('name' => 'john smith', 'age' => 70) person.delete_field('namedddd') end
you can execute code here : https://repl.it/qvk/2
the purpose overide delete_field of openstruct using both prepend , refine.
but execution return nameerror: method `namedddd' not defined in class.
what's wrong in code?
if want use refinement
s, should use using
instead of include
:
module testy using interactorsrefine person = openstruct.new('name' => 'john smith', 'age' => 70) person.delete_field('namedddd') end
hope helps!
Comments
Post a Comment