Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Virtus cannot define attributes on Objects #28

Closed
postmodern opened this Issue Nov 8, 2011 · 5 comments

Comments

Projects
None yet
3 participants
Contributor

postmodern commented Nov 8, 2011

I was trying to replace Parameters with Virtus. One of the features of Parameters, is being able to define parameters on Objects as well as Classes. Virtus does not want to be extended into an Object.

class Test
end
obj = Test.new
obj.extend Virtus::ClassMethods

NoMethodError: undefined method `const_set' for #<Test:0x00000002aeb878>
    /home/hal/.rvm/gems/ruby-1.9.3-p0/gems/virtus-0.0.9/lib/virtus/class_methods.rb:16:in `extended'
Owner

solnic commented Nov 8, 2011

This has a very low priority now. I'll mark it as a suggestion and we can work on it later.

Collaborator

emmanuel commented Dec 21, 2011

I believe this may be resolved with the work in #41, though I haven't verified this specific use-case.

Collaborator

emmanuel commented Dec 21, 2011

Shoot, I just reviewed #41 and it turns out I used #module_eval, which is not going to work with arbitrary objects. I'm fairly sure the call to #module_eval could be harmlessly replaced with a call to #instance_eval instead (or, AFAICT, #__send__ would work fine as well): https://github.com/solnic/virtus/pull/41/files#L4R16

Owner

solnic commented Feb 25, 2012

@emmanuel can you follow up please?

Owner

solnic commented Jun 8, 2012

This is done!

@solnic solnic closed this Jun 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment