Skip to content
This repository

Virtus cannot define attributes on Objects #28

postmodern opened this Issue November 07, 2011 · 5 comments

3 participants

Postmodern Piotr Solnica Emmanuel Gomez

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
obj =
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'
Piotr Solnica

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

Emmanuel Gomez

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

Emmanuel Gomez

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):

Piotr Solnica

@emmanuel can you follow up please?

Piotr Solnica solnic closed this June 08, 2012
Piotr Solnica
solnic commented June 08, 2012

This is done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.