Sha256: fdebb2cfd5a4cb9dbd3cd011f8668de3f9dd1ce05aff270b7990bca4ac45b629

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

module Siteleaf
  class Site < Entity

    attr_accessor :title, :domain, :timezone
    attr_reader :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", {"url" => url, "template" => template}
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
siteleaf-0.9.12 lib/siteleaf/site.rb