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
239 240 241 |
# File 'lib/active_fedora/file.rb', line 239 def content local_or_remote_content(true) end |
#content=(string_or_io) ⇒ Object
234 235 236 237 |
# File 'lib/active_fedora/file.rb', line 234 def content= string_or_io content_will_change! unless @content == string_or_io @content = string_or_io end |
#retrieve_content ⇒ Object
262 263 264 |
# File 'lib/active_fedora/file.rb', line 262 def retrieve_content ldp_source.get.body end |
#save ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/active_fedora/file.rb', line 243 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 = headers end else ldp_source.update do |req| req.headers = headers end end reset changed_attributes.clear end |