Class: ActiveFedora::Datastream
- Inherits:
-
Rubydora::Datastream
- Object
- Rubydora::Datastream
- ActiveFedora::Datastream
- Extended by:
- Deprecation
- Defined in:
- lib/active_fedora/datastream.rb
Overview
This class represents a Fedora datastream
Direct Known Subclasses
NokogiriDatastream, NomDatastream, RDFDatastream, RelsExtDatastream
Instance Attribute Summary collapse
-
#digital_object ⇒ Object
writeonly
Sets the attribute digital_object.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
Class Method Summary collapse
-
.from_xml(tmpl, node) ⇒ Object
Populate a Datastream object based on the “datastream” node from a FOXML file.
Instance Method Summary collapse
- #create ⇒ Object
-
#dirty ⇒ Object
Deprecated.
-
#dirty=(value) ⇒ Object
Deprecated.
-
#dirty? ⇒ Boolean
Test whether this datastream been modified since it was last saved Deprecated.
-
#initialize(digital_object = nil, dsid = nil, options = {}) ⇒ Datastream
constructor
A new instance of Datastream.
- #inspect ⇒ Object
-
#metadata? ⇒ boolean
abstract
Does this datastream contain metadata (not file data).
- #new_object? ⇒ Boolean
- #profile_from_hash(profile_hash) ⇒ Object
- #save ⇒ Object
-
#serialize! ⇒ Object
serializes any changed data into the content field.
-
#solrize_profile ⇒ Object
:nodoc:.
-
#to_param ⇒ Object
compatibility method for rails’ url generators.
- #to_solr(solr_doc = Hash.new) ⇒ Object
- #validate_content_present ⇒ Object
Constructor Details
#initialize(digital_object = nil, dsid = nil, options = {}) ⇒ Datastream
Returns a new instance of Datastream.
9 10 11 12 |
# File 'lib/active_fedora/datastream.rb', line 9 def initialize(digital_object=nil, dsid=nil, ={}) ## When you use the versions feature of rubydora (0.5.x), you need to have a 3 argument constructor super end |
Instance Attribute Details
#digital_object=(value) ⇒ Object (writeonly)
Sets the attribute digital_object
6 7 8 |
# File 'lib/active_fedora/datastream.rb', line 6 def digital_object=(value) @digital_object = value end |
#last_modified ⇒ Object
Returns the value of attribute last_modified.
7 8 9 |
# File 'lib/active_fedora/datastream.rb', line 7 def last_modified @last_modified end |
Class Method Details
.from_xml(tmpl, node) ⇒ Object
Populate a Datastream object based on the “datastream” node from a FOXML file
79 80 81 82 83 |
# File 'lib/active_fedora/datastream.rb', line 79 def self.from_xml(tmpl, node) Deprecation.deprecated_method_warning(self, :from_xml) tmpl.controlGroup= node['CONTROL_GROUP'] tmpl end |
Instance Method Details
#create ⇒ Object
68 69 70 71 |
# File 'lib/active_fedora/datastream.rb', line 68 def create super self end |
#dirty ⇒ Object
Deprecated
39 40 41 |
# File 'lib/active_fedora/datastream.rb', line 39 def dirty changed? end |
#dirty=(value) ⇒ Object
Deprecated
45 46 47 48 49 50 51 |
# File 'lib/active_fedora/datastream.rb', line 45 def dirty=(value) if value content_will_change! # an innocent hack to pretend something has changed else changed_attributes.clear end end |
#dirty? ⇒ Boolean
Test whether this datastream been modified since it was last saved Deprecated
27 28 29 |
# File 'lib/active_fedora/datastream.rb', line 27 def dirty? changed? end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/active_fedora/datastream.rb', line 14 def inspect "#<#{self.class} @pid=\"#{digital_object ? pid : nil}\" @dsid=\"#{dsid}\" @controlGroup=\"#{controlGroup}\" changed=\"#{changed?}\" @mimeType=\"#{mimeType}\" >" end |
#metadata? ⇒ boolean
Override this in your concrete datastream class.
Returns does this datastream contain metadata (not file data).
34 35 36 |
# File 'lib/active_fedora/datastream.rb', line 34 def false end |
#new_object? ⇒ Boolean
54 55 56 |
# File 'lib/active_fedora/datastream.rb', line 54 def new_object? new? end |
#profile_from_hash(profile_hash) ⇒ Object
97 98 99 100 101 |
# File 'lib/active_fedora/datastream.rb', line 97 def profile_from_hash(profile_hash) profile_hash.each_pair do |key,value| profile[key] = value.to_s end end |
#save ⇒ Object
63 64 65 66 |
# File 'lib/active_fedora/datastream.rb', line 63 def save super self end |
#serialize! ⇒ Object
serializes any changed data into the content field
74 75 |
# File 'lib/active_fedora/datastream.rb', line 74 def serialize! end |
#solrize_profile ⇒ Object
:nodoc:
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/active_fedora/datastream.rb', line 85 def solrize_profile # :nodoc: profile_hash = {} profile.each_pair do |property,value| if property =~ /Date/ value = Time.parse(value) unless value.is_a?(Time) value = value.xmlschema end profile_hash[property] = value end profile_hash end |
#to_param ⇒ Object
compatibility method for rails’ url generators. This method will urlescape escape dots, which are apparently invalid characters in a dsid.
21 22 23 |
# File 'lib/active_fedora/datastream.rb', line 21 def to_param dsid.gsub(/\./, '%2e') end |
#to_solr(solr_doc = Hash.new) ⇒ Object
103 104 105 |
# File 'lib/active_fedora/datastream.rb', line 103 def to_solr(solr_doc = Hash.new) solr_doc end |
#validate_content_present ⇒ Object
59 60 61 |
# File 'lib/active_fedora/datastream.rb', line 59 def validate_content_present has_content? end |