Sha256: 8e59506669e820172e37e13ba1e4f00ca5991a32fdf2a1171f2c8ca87e3b3826

Contents?: true

Size: 813 Bytes

Versions: 6

Compression:

Stored size: 813 Bytes

Contents

module Siteleaf
  class Collection < Entity

    attr_accessor :title, :path, :permalink, :output, :site_id, :user_id, :metadata
    attr_reader :id, :directory, :created_at, :updated_at

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

    def entity_endpoint
      ::File.join(create_endpoint, identifier)
    end

    def identifier
      path
    end

    def site
      Site.find(site_id)
    end

    def 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

    def filename
      path
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
siteleaf-2.3.0 lib/siteleaf/collection.rb
siteleaf-2.2.1 lib/siteleaf/collection.rb
siteleaf-2.2.0 lib/siteleaf/collection.rb
siteleaf-2.1.2 lib/siteleaf/collection.rb
siteleaf-2.1.1 lib/siteleaf/collection.rb
siteleaf-2.1.0 lib/siteleaf/collection.rb