Module: ActiveFedora::File::Persistence
- Included in:
- ActiveFedora::File
- Defined in:
- lib/active_fedora/file.rb
Overview
Persistence is an included module, so that we can include other modules which override these methods
Instance Method Summary collapse
Instance Method Details
#content ⇒ Object
246 247 248 |
# File 'lib/active_fedora/file.rb', line 246 def content local_or_remote_content(true) end |
#content=(string_or_io) ⇒ Object
241 242 243 244 |
# File 'lib/active_fedora/file.rb', line 241 def content= string_or_io content_will_change! unless @content == string_or_io @content = string_or_io end |
#retrieve_content ⇒ Object
269 270 271 |
# File 'lib/active_fedora/file.rb', line 269 def retrieve_content ldp_source.get.body end |
#save ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/active_fedora/file.rb', line 250 def save(*) return unless content_changed? headers = { 'Content-Type'.freeze => mime_type, 'Content-Length'.freeze => content.size.to_s } headers['Content-Disposition'.freeze] = "attachment; filename=\"#{URI.encode(@original_name)}\"" if @original_name ldp_source.content = content if new_record? ldp_source.create do |req| req.headers.merge!(headers) end else ldp_source.update do |req| req.headers.merge!(headers) end end reset changed_attributes.clear end |