let's use 'couchrest_type'
-
hkstar
If we're messing with things, I would actually prefer to see the field name changed to something more generic like "document_class" or "object_type" or "instance_of" or something. The label couchrest_type seems to imply that the document itself is related to CouchRest.
Agree on losing the hyphen, though, that's just a good habit in general and makes the JS side look that much nicer.
-
Priit Tamboom
I agree, however I don't mind using 'couchrest_type' by the way, at least I'm sure it does not clash with anything in the future. I have playied with other ruby interfaces using: ruby_class, class etc. First I was scared to use 'class' or something very general, but more I play with couchdb more I think it might be ok with very general key as well.
-
hkstar
Priit: I don't think it will be a problem using generic-sounding names, as long as you stay away from conflicting ruby keywords like class, type, object_id, etc. Maybe instance_of was a bad suggestion!
Unless the developer rules differently, I think I'm going to go with record_class or document_class or something. I don't really want to rely on the built-in system anyway since I will be calling from inside multiple modules, so the couchrest-type gets written as BaseModule::SubModule::Class or similar. This might cause problems if I decide to move a class to another module so I want to specify my own names anyway.
Maybe a way to specify the couchrest-type used would be handy to avoid the type of situation I'm talking about. Perhaps use_class_name to go under use_database?
-
James R. Bracy
Attached is a patch that makes the field is customizable, but it will default to
couchrest_type. For example:class Example < CouchRest:Model set_inheritance_field "type" endAlternately you could set the field across all models by doing
CouchRest::Model.inheritance_field = 'my_custom_field'orCouchRest::Model.set_inheritance_field = 'my_custom_field'`Hope this helps. I created 2 specs for it as well.
-
Max Aller
+1 James' patch with the suggestion that there be only one method for assigning a new default custom field, to reduce clutter in the code. My vote is for the "set_" variant.
-
CodeMonkeyKevin
- Milestone order changed from 0 to 0
+1 for James patch as couchrest_type is so odd when in multi-lang env. If not at lease _doc_type will do fine.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
