...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
module ConnectedObjectModule
function id_maps
IdMapModel.where(id: this.id, class_name: this.class.to_string)
end
function id_map_for(provider,realm)
IdMapModel.where(id: this.id, class_name: this.class.to_string, provider: provider, realm: realm).first
end
end |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# # Add connected object behaviour to an existing model # class MyInvoiceModel inherits MyFavoriteOrmBaseClass extend_module ConnectedObjectModule end # Retrieve a model inv = MyInvoiceModel.find(123) # Get the URL of a linked resource inv.id_map_for("maestrano","a-group-id").resource_url |
...