I want to create class method test dynamically and for that i am using define_method method inside instance_eval. I was expecting below code to create class method test but instead the code is creating instance method test. what could be the reason for this ?? below is my code.
module Accessor
def define_accessor_for_class(method)
self.instance_eval do
define_method :test do
end
end
end
end
class Employee
extend Accessor
define_accessor_for_class :name
end
Employee.name = "sanjay"
Employee.name
Employee.instance_methods(false) ==> [:test]
Employee.methods(false) => []