Sha256: 4bc1a1613205f36a96385123555c278187917daabc9f985f0282ee3d355bc434
Contents?: true
Size: 1.69 KB
Versions: 60
Compression:
Stored size: 1.69 KB
Contents
var Entity = function(data){ this.code = data.code if (data.name !== undefined) this.name = data.name else this.name = data.code this.type = data.type this.format = data.format if (undefined === data.info) this.info = {} else this.info = data.info if (this.format === undefined && this.info !== undefined) this.format = this.info['format'] this.full_type = function(){ var full_type if (this.format){ full_type = this.type + ":" + this.format } else { full_type = this.type } return full_type } this.link_info = function(){ var link_info = this.info delete link_info['format'] return link_info } this.url = function(){ var url = "/entity/" + this.full_type() + "/" + this.code url = add_parameters(url, this.link_info()) return url } this.property = function(name, args){ var url = "/entity_property/" + name + "/" + this.full_type() + "/" + this.code url = add_parameters(url, this.link_info()) if (undefined !== args) url = add_parameter(url, "args", JSON.stringify(args)) return rbbt.insist_request({url: url}) } } var FavouriteEntities = function(by_type){ for (type in by_type){ this[type] = by_type[type] } } FavouriteEntities.deserialize = function(data){ data = JSON.parse(data) favourite_entities = {} forHash(data, function(type, type_data){ favourite_entities[type] = {} forHash(type_data, function(code, info){ info.code = code info.type = type favourite_entities[type][code] = new Entity(info) }) }) return favourite_entities } FavouriteEntities.get = function(){ return m.request({method: 'GET', url: '/favourite_entities', type: FavouriteEntities, deserialize: FavouriteEntities.deserialize}) }
Version data entries
60 entries across 60 versions & 1 rubygems