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 refinements, 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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -