myClass compile: someCode classified: aProtocolName.
This might be a good example to add to Deep Into Pharo (but I haven't read it yet, so its too much for me right now to work out where it should go). Anyone interested in doing this? Otherwise maybe I could drop it into a scratchpad at the back of the book.
cheers -ben
Hernán Morales Durand wrote:Yes you need it because when doing code generation you cannot always assume target class is present. Besides using RB you can confirm through the NautilusRefactoring which is useful for massive changes:Cheers,
| model |
model := RBNamespace new.
(model classNamed: #Model)
compile: 'asString ^ String empty'
classified: #(accessing).
(ChangesBrowser changes: model changes changes) openWithSpec
Hernán
2014-07-17 13:55 GMT-03:00 Esteban Lorenzano <[hidden email]>:
Hi,you do not need the RBNamespace mediation, just do:
Model compile: ‘method ...’ classified: ‘accessing’.
Esteban
On 17 Jul 2014, at 18:52, Mark Rizun <[hidden email]> wrote:
Thanks Hernan
17 лип. 2014 18:29, користувач "Hernán Morales Durand" <[hidden email]> написав:
Cheers,and the new method is recorded in the .changes fileNo. Adding a method is not a refactoring. You should use RBAddMethodChange:| model |
model := RBNamespace new.
(model classNamed: #Model)
compile: 'asString ^ String empty'
classified: #(accessing).
model changes execute.
Hernán
2014-07-17 11:08 GMT-03:00 Mark Rizun <[hidden email]>:
Thank you all. Problem is solved, I just used RBAddMethodRefactoring.
Mark
2014-07-17 16:07 GMT+02:00 Baptiste Quide <[hidden email]>:
I think you have to add a "RGMethodDefinition" or a "CompiledMethod".Obviously in a class methodDict the values are CompiledMethod.
Regards,
De: "Sebastian Tleye" <[hidden email]>
À: "Any question about pharo is welcome" <[hidden email]>
Envoyé: Jeudi 17 Juillet 2014 16:03:52
Objet: Re: [Pharo-users] Adding method to class
I don't know what RBMethod is, but you can do
aClass compile: source.
For example:
Array compile: 'newMethod ^ 1'
I don't know if it answers your question.
Regards
2014-07-17 15:57 GMT+02:00 Mark Rizun <[hidden email]>:
P.S. obviously, my method is added to newMethods var, but it is not disblayed in my class.
2014-07-17 15:53 GMT+02:00 Mark Rizun <[hidden email]>:
Hi guys!
How can I add method (I have /RBMethod/) to a class in code?
I'm asking because existing method /addMethod:/ in /RBAbstractClass/ isn't
working.
Here is a piece of my code:
/method:= RBMethod for: class source: ('^ ', newName asString) selector:
newName asSymbol.
class addMethod: getter./
Best
Mark
--
View this message in context: http://forum.world.st/Adding-method-to-class-tp4768282.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Free forum by Nabble | Edit this page |