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
231 232 233 |
# File 'lib/active_fedora/file.rb', line 231 def content local_or_remote_content(true) end |
#content=(string_or_io) ⇒ Object
226 227 228 229 |
# File 'lib/active_fedora/file.rb', line 226 def content= string_or_io content_will_change! unless @content == string_or_io @content = string_or_io end |
#retrieve_content ⇒ Object
254 255 256 |
# File 'lib/active_fedora/file.rb', line 254 def retrieve_content ldp_source.get.body end |
#save ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/active_fedora/file.rb', line 235 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 |