Sha256: 8b68802affc6495a3b2d57f3180869835e584bf827ac0c0865ab7a57f77bd608
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
module RailsConnector module ObjBody # Returns the body (main content) of the Obj for non-binary Objs. # Returns nil for binary Objs. def body if binary? nil else StringTagging.tag_as_html(read_attribute('body'), self) end end # for binary Objs body_length equals the file size # for non-binary Objs body_length equals the number of characters in the body (main content) def body_length if binary? blob = find_blob blob ? blob.length : 0 else (body || "").length end end # returns an URL to retrieve the Obj's body for binary Objs. # returns nil for non-binary Objs. def body_data_url if binary? blob = find_blob blob.url if blob end end def body_data_path # :nodoc: # not needed/supported when using cloud connector. nil end # returns the content type of the Obj's body for binary Objs. # returns nil for non-binary Objs. def body_content_type if binary? blob = find_blob if blob blob.content_type else "application/octet-stream" end end end private def find_blob blob_spec = read_attribute('blob') Blob.find(blob_spec["id"]) if blob_spec end end end # module RailsConnector
Version data entries
3 entries across 3 versions & 1 rubygems