Sha256: 876df3e582987472bdc7350d2a44dde2ddd140f2913b88bc9b592cf29407c819

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

module StorageRoom
  # A collection is used to define the structure of a data set. 
  class Collection < Model        
    class << self                  
      def index_path # :nodoc:
        '/collections'
      end
      
      def show_path(collection_id) # :nodoc:
        "#{index_path}/#{collection_id}"
      end
      
      def resources_path(collection_id) # :nodoc:
        "#{show_path(collection_id)}/resources"
      end
      
      def json_name # :nodoc:
        'collection'
      end
    end
    
    # Load all the resources of a collection
    def resources
      Array.load(self[:@resources_url])
    end
    
    # The class of the collection's objects
    def resource_class
      StorageRoom.class_for_name(self[:identifier].classify)
    end

    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
storage_room-0.1.1 lib/storage_room/models/collection.rb