class A has_one :b, B end will fail: undefined method `has_one' for Slot:Class (NoMethodError) while class A property :x, String has_one :b, B end will succeed. What is the thinking behind this? I am sure there is some other explicit declaration I can make so that first version works, but this I find this kind of magic inconsistent and confusing. What are the rules of this magic? What is the simple explicit way to make a class persistent?
(2 attempts)
Rayman answered:
property is the magic way, but this is about to change as George finishes his Og refactoring.
in future version, property is left as an alias but the standard ruby way attr_accessor is recommended.
There are other ways to manage a class. One should probably consult ML for those 'hacks'. Be warned tho, the API has been living a lot and many of the previous explicit ways of "enchanting" a class have been deprecated -- use the magic way unless you really need a workaround
I often add a dummy property just to get a class enchanted, like this:
class Foo property :dummy, TrueClass joins_many Bar end
dklangst answered:
As I understand Og (version 0.30.0 and earlier), only classes that contain one or more 'property'(s) are enchanted and made persistent. So in your first case, given there is no property within the class, Og does not make it one of its 'managed' classes, where case two is an Og managed class...