Sha256: f3707360e08e14abec4d57adfed6050b8f01dc5d6c6e6e77a989651eabd339fb

Contents?: true

Size: 807 Bytes

Versions: 2

Compression:

Stored size: 807 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 entries_path(collection_id) # :nodoc:
        "#{show_path(collection_id)}/entries"
      end
      
      def json_name # :nodoc:
        'collection'
      end
    end
    
    # Load all the entries of a collection
    def entries
      Array.load(self[:@entries_url])
    end
    
    # The class of the collection's objects
    def entry_class
      StorageRoom::Entry.class_with_options(self[:name].classify, :collection_path => self.url)
    end

    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
storage_room-0.2.1 lib/storage_room/models/collection.rb
storage_room-0.2.0 lib/storage_room/models/collection.rb