Class: Siteleaf::Document

Inherits:
Content show all
Defined in:
lib/siteleaf/document.rb

Instance Attribute Summary collapse

Attributes inherited from Content

#basename, #body, #created_at, #date, #directory, #filename, #id, #metadata, #path, #permalink, #sha, #site_id, #title, #updated_at, #url, #user_id, #visibility

Attributes inherited from Entity

#error, #message

Instance Method Summary collapse

Methods inherited from Content

#draft?, #hidden?, #site, #to_file, #visible?

Methods inherited from Entity

all, #attributes, #attributes=, class_name, create, delete, #delete, endpoint, #entity_endpoint, find, #identifier, #initialize, #save

Constructor Details

This class inherits a constructor from Siteleaf::Entity

Instance Attribute Details

#collection_pathObject

Returns the value of attribute collection_path.



4
5
6
# File 'lib/siteleaf/document.rb', line 4

def collection_path
  @collection_path
end

Instance Method Details

#collectionObject



10
11
12
# File 'lib/siteleaf/document.rb', line 10

def collection
  Collection.find(collection_identifier)
end

#collection_identifierObject



14
15
16
# File 'lib/siteleaf/document.rb', line 14

def collection_identifier
  collection_path || directory.match(/_(.*)/).try(:last)
end

#create_endpointObject



6
7
8
# File 'lib/siteleaf/document.rb', line 6

def create_endpoint
  ::File.join("sites", site_id, "collections", collection_identifier, "documents")
end