Sha256: e3fd07a0510e7742e763a1a21e9dc1ccf1833c13df0f27f2b14fb55d7ac8a53b

Contents?: true

Size: 815 Bytes

Versions: 5

Compression:

Stored size: 815 Bytes

Contents

module Siteleaf
  class Asset < Entity

    attr_accessor :file, :filename, :replace, :site_id, :page_id, :post_id, :theme_id, :meta
    attr_reader :id, :url, :content_type, :filesize, :checksum, :created_at, :updated_at

    def create_endpoint
      if !self.post_id.nil?
        "posts/#{self.post_id}/assets"
      elsif !self.page_id.nil?
        "pages/#{self.page_id}/assets"
      elsif !self.theme_id.nil?
        "sites/#{self.site_id}/theme/assets"
      else
        "sites/#{self.site_id}/assets"
      end
    end

    def post
      Post.find(self.post_id) if self.post_id
    end

    def page
      Page.find(self.page_id) if self.page_id
    end

    def theme
      Theme.find(self.theme_id) if self.theme_id
    end

    def site
      Site.find(self.site_id) if self.site_id
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
siteleaf-1.0.11 lib/siteleaf/asset.rb
siteleaf-1.0.10 lib/siteleaf/asset.rb
siteleaf-1.0.9 lib/siteleaf/asset.rb
siteleaf-1.0.8 lib/siteleaf/asset.rb
siteleaf-1.0.7 lib/siteleaf/asset.rb