Sha256: 1b4315b265b2f6bde0072c13e4c776fa763a4801acefe3847bc6deae6696770a
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module StorageRoom class Resource < Model class << self def index_path "/collections/#{collection_id}/resources" end def show_path(resource_id) "#{index_path}/#{resource_id}" end def collection_path "/collections/#{collection_id}" end def collection_id self.name.gsub('StorageRoom::', '').tableize end def json_name 'resource' end def search_path(parameters = {}) parameters.present? ? "#{index_path}?#{parameters.to_query}" : index_path end def search(parameters = {}) Array.load(search_path(parameters)) end end def set_from_api(attributes) super(attributes) self.attributes.each do |k, v| if v.is_a?(Hash) && v[:@type].present? object = StorageRoom.class_for_name(v[:@type]).new object.set_from_api(v) self.attributes[k] = object end end self.attributes end def collection Collection.load(self[:@collection_url] || self.class.collection_path) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
storage_room-0.1.0 | lib/storage_room/models/resource.rb |