Sha256: 31a5da016936988402f4ccb5e11c7f8c0e6e73614483c19f81b81c9f78210828

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

module Siteleaf
  class Site < Entity

    attr_accessor :id, :title, :domain, :timezone, :user_id, :created_at, :updated_at
    protected :id=, :user_id=, :created_at=, :updated_at=
    
    def self.find_by_domain(domain)
      result = Client.get "sites", {"domain" => domain}
      self.new(result.first) if result and result.size >= 1
    end
    
    def pages
      result = Client.get "sites/#{self.id}/pages"
      result.map { |r| Page.new(r) } if result
    end
    
    def resolve(url = '/')
      Client.get "sites/#{self.id}/resolve", {"url" => url}
    end
    
    def preview(url = '/', template = nil)
      Client.post "sites/#{self.id}/preview.html", {"url" => url, "template" => template}
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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