lib/siteleaf/collection.rb in siteleaf-2.0.0.pre.beta7 vs lib/siteleaf/collection.rb in siteleaf-2.0.0.pre.beta9
- old
+ new
@@ -1,21 +1,34 @@
module Siteleaf
class Collection < Entity
- attr_accessor :title, :path, :permalink, :output, :site_id, :metadata
+ attr_accessor :title, :path, :permalink, :output, :site_id, :user_id, :metadata
attr_reader :id, :directory, :created_at, :updated_at
def create_endpoint
- "sites/#{self.site_id}/collections"
+ ::File.join("sites", site_id, "collections")
end
+ def entity_endpoint
+ ::File.join(create_endpoint, identifier)
+ end
+
+ def identifier
+ path
+ end
+
def site
- Site.find(self.site_id)
+ Site.find(site_id)
end
def documents
- result = Client.get "collections/#{self.id}/documents"
+ result = Client.get "#{entity_endpoint}/documents"
result.map { |r| Document.new(r) } if result.is_a? Array
+ end
+
+ def files
+ result = Client.get "#{entity_endpoint}/files"
+ result.map { |r| File.new(r) } if result.is_a? Array
end
def output?
output == true
end
\ No newline at end of file