[Rails] Access block scope from AR object
I need to create a sort of transaction around some Active Record objects that perform many insert/updates.
Example:
class MyObject
def transaction &block
@my_var = value
self.instance_eval block
end
end
MyObject.new.transaction do
Model.create
Model.collection.create
etc......
end
I have a gem that add a method into AR::Base and I need to read the variables setted by the transaction inside the method at runtime.
Any way I can access the block scope from there inside?
Thanks
Andrea
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Xo1PIgOKoVIJ.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home