Class: ActiveFedora::Datastream

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

Overview

This class represents a Fedora datastream

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Datastream.



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

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
  self.fields={}
  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.



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

def digital_object=(value)
  @digital_object = value
end

#fieldsObject

Returns the value of attribute fields.



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

def fields
  @fields
end

#last_modifiedObject

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

Parameters:

  • tmpl (ActiveFedora::Datastream)

    the Datastream object that you are building

  • node (Nokogiri::XML::Node)

    the “foxml:datastream” node from a FOXML file



80
81
82
83
84
# File 'lib/active_fedora/datastream.rb', line 80

def self.from_xml(tmpl, node)
  Deprecation.deprecated_method_warning(self, :from_xml)
  tmpl.controlGroup= node['CONTROL_GROUP']
  tmpl
end

Instance Method Details

#createObject



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

def create
  super
  self
end

#dirtyObject

Deprecated



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

def dirty
  changed?
end

#dirty=(value) ⇒ Object

Deprecated



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

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

Returns:

  • (Boolean)


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

def dirty?
  changed?
end

#inspectObject



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

def inspect
  "#<#{self.class}:#{self.hash} @pid=\"#{digital_object ? pid : nil}\" @dsid=\"#{dsid}\" @controlGroup=\"#{controlGroup}\" changed=\"#{changed?}\" @mimeType=\"#{mimeType}\" >"
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)



35
36
37
# File 'lib/active_fedora/datastream.rb', line 35

def metadata?
  false
end

#new_object?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/active_fedora/datastream.rb', line 55

def new_object?
  new?
end

#profile_from_hash(profile_hash) ⇒ Object



98
99
100
101
102
# File 'lib/active_fedora/datastream.rb', line 98

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

#saveObject



64
65
66
67
# File 'lib/active_fedora/datastream.rb', line 64

def save
  super
  self
end

#serialize!Object

serializes any changed data into the content field



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

def serialize!
end

#solrize_profileObject

:nodoc:



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/active_fedora/datastream.rb', line 86

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.



22
23
24
# File 'lib/active_fedora/datastream.rb', line 22

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

#to_solr(solr_doc = Hash.new) ⇒ Object



104
105
106
# File 'lib/active_fedora/datastream.rb', line 104

def to_solr(solr_doc = Hash.new)
  solr_doc
end

#validate_content_presentObject



60
61
62
# File 'lib/active_fedora/datastream.rb', line 60

def validate_content_present
  has_content?
end