Class: ActiveFedora::SolrDigitalObject
- Inherits:
-
Object
- Object
- ActiveFedora::SolrDigitalObject
- Includes:
- DigitalObject::DatastreamBootstrap
- Defined in:
- lib/active_fedora/solr_digital_object.rb
Instance Attribute Summary collapse
-
#datastreams ⇒ Object
readonly
Returns the value of attribute datastreams.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#original_class ⇒ Object
Returns the value of attribute original_class.
-
#ownerId ⇒ Object
readonly
Returns the value of attribute ownerId.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#solr_doc ⇒ Object
readonly
Returns the value of attribute solr_doc.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #freeze ⇒ Object
-
#initialize(solr_doc, profile_hash, klass = ActiveFedora::Base) ⇒ SolrDigitalObject
constructor
A new instance of SolrDigitalObject.
- #new? ⇒ Boolean
Methods included from DigitalObject::DatastreamBootstrap
Constructor Details
#initialize(solr_doc, profile_hash, klass = ActiveFedora::Base) ⇒ SolrDigitalObject
Returns a new instance of SolrDigitalObject.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_fedora/solr_digital_object.rb', line 6 def initialize(solr_doc, profile_hash, klass=ActiveFedora::Base) @solr_doc = solr_doc @pid = solr_doc[SOLR_DOCUMENT_ID] @profile = {} profile_hash.each_pair { |key,value| @profile[key] = value.to_s if key =~ /^obj/ } @profile['objCreateDate'] ||= Time.now.xmlschema @profile['objLastModDate'] ||= @profile['objCreateDate'] @datastreams = {} dsids = profile_hash['datastreams'].keys original_class = klass missing = dsids - klass.ds_specs.keys missing.each do |dsid| #Initialize the datastreams that are in the solr document, but not found in the classes spec. mime_type = profile_hash['datastreams'][dsid]['dsMIME'] ds_class = mime_type =~ /[\/\+]xml$/ ? OmDatastream : Datastream @datastreams[dsid] = ds_class.new(self, dsid) end @label = @profile['objLabel'] @state = @profile['objState'] @ownerId = @profile['objOwnerId'] end |
Instance Attribute Details
#datastreams ⇒ Object (readonly)
Returns the value of attribute datastreams.
4 5 6 |
# File 'lib/active_fedora/solr_digital_object.rb', line 4 def datastreams @datastreams end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/active_fedora/solr_digital_object.rb', line 4 def label @label end |
#original_class ⇒ Object
Returns the value of attribute original_class.
5 6 7 |
# File 'lib/active_fedora/solr_digital_object.rb', line 5 def original_class @original_class end |
#ownerId ⇒ Object (readonly)
Returns the value of attribute ownerId.
4 5 6 |
# File 'lib/active_fedora/solr_digital_object.rb', line 4 def ownerId @ownerId end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
4 5 6 |
# File 'lib/active_fedora/solr_digital_object.rb', line 4 def pid @pid end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
4 5 6 |
# File 'lib/active_fedora/solr_digital_object.rb', line 4 def profile @profile end |
#solr_doc ⇒ Object (readonly)
Returns the value of attribute solr_doc.
4 5 6 |
# File 'lib/active_fedora/solr_digital_object.rb', line 4 def solr_doc @solr_doc end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
4 5 6 |
# File 'lib/active_fedora/solr_digital_object.rb', line 4 def state @state end |
Instance Method Details
#freeze ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/active_fedora/solr_digital_object.rb', line 31 def freeze @finished = true @profile.freeze @datastreams.freeze class << self #Once this instance is frozen create a repository method just for this one instance. define_method :repository do ActiveFedora::Base.connection_for_pid(self.pid) end end self end |
#new? ⇒ Boolean
44 45 46 |
# File 'lib/active_fedora/solr_digital_object.rb', line 44 def new? false end |