Class: ActiveFedora::Datastream

Inherits:
Rubydora::Datastream
  • Object
show all
Defined in:
lib/active_fedora/datastream.rb

Overview

This class represents a Fedora datastream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(digital_object = nil, dsid = nil, options = {}) ⇒ Datastream

Returns a new instance of Datastream.



8
9
10
11
# File 'lib/active_fedora/datastream.rb', line 8

def initialize(digital_object=nil, dsid=nil, options={})
  ## 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

Parameters:

  • value

    the value to set the attribute digital_object to.



5
6
7
# File 'lib/active_fedora/datastream.rb', line 5

def digital_object=(value)
  @digital_object = value
end

#last_modifiedObject

Returns the value of attribute last_modified.



6
7
8
# File 'lib/active_fedora/datastream.rb', line 6

def last_modified
  @last_modified
end

Instance Method Details

#createObject



46
47
48
49
# File 'lib/active_fedora/datastream.rb', line 46

def create
  super
  self
end

#inspectObject



20
21
22
# File 'lib/active_fedora/datastream.rb', line 20

def inspect
  "#<#{self.class} @pid=\"#{digital_object ? pid : nil}\" @dsid=\"#{dsid}\" @controlGroup=\"#{controlGroup}\" changed=\"#{changed?}\" @mimeType=\"#{mimeType}\" >"
end

#labelObject Also known as: dsLabel



15
16
17
# File 'lib/active_fedora/datastream.rb', line 15

def label
  Array(realLabel).first
end

#metadata?boolean

This method is abstract.

Override this in your concrete datastream class.

Returns does this datastream contain metadata (not file data).

Returns:

  • (boolean)

    does this datastream contain metadata (not file data)



33
34
35
# File 'lib/active_fedora/datastream.rb', line 33

def metadata?
  false
end

#profile_from_hash(profile_hash) ⇒ Object



67
68
69
70
71
# File 'lib/active_fedora/datastream.rb', line 67

def profile_from_hash(profile_hash)
  profile_hash.each_pair do |key,value|
    profile[key] = value
  end
end

#realLabelObject



13
# File 'lib/active_fedora/datastream.rb', line 13

alias_method :realLabel, :label

#saveObject



41
42
43
44
# File 'lib/active_fedora/datastream.rb', line 41

def save
  super
  self
end

#serialize!Object

serializes any changed data into the content field



52
53
# File 'lib/active_fedora/datastream.rb', line 52

def serialize!
end

#solrize_profileObject

:nodoc:



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/active_fedora/datastream.rb', line 55

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_paramObject

compatibility method for rails’ url generators. This method will urlescape escape dots, which are apparently invalid characters in a dsid.



27
28
29
# File 'lib/active_fedora/datastream.rb', line 27

def to_param
  dsid.gsub(/\./, '%2e')
end

#to_solr(solr_doc = Hash.new) ⇒ Object



73
74
75
# File 'lib/active_fedora/datastream.rb', line 73

def to_solr(solr_doc = Hash.new)
  solr_doc
end

#validate_content_presentObject



37
38
39
# File 'lib/active_fedora/datastream.rb', line 37

def validate_content_present
  has_content?
end