Sha256: f7739b8c32ed5aa06d342189b0a7aff0269048b7014d858491fe4b126b5b7dcc

Contents?: true

Size: 691 Bytes

Versions: 2

Compression:

Stored size: 691 Bytes

Contents

module Siteleaf
  class Page < Entity

    attr_accessor :id, :title, :body, :slug, :url, :parent_id, :site_id, :published_at, :created_at, :updated_at, :meta
    protected :id=, :created_at=, :updated_at=
    
    def create_endpoint
      "sites/#{self.site_id}/pages"
    end
    
    def site
      Site.find(self.site_id) if self.site_id
    end
    
    def posts
      result = Client.get "pages/#{self.id}/posts"
      result.map { |r| Post.new(r) } if result
    end
    
    def pages
      result = Client.get "pages/#{self.id}/pages"
      result.map { |r| self.new(r) } if result
    end
    
    def page
      Page.find(self.parent_id) if self.parent_id
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
siteleaf-0.8.1 lib/siteleaf/page.rb
siteleaf-0.8.0 lib/siteleaf/page.rb