Class: Permalink
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Permalink
- Defined in:
- app/models/permalink.rb
Overview
attribute context_obj_serialized has an XML OpenURL ContextObject sufficient to restore the original request and resolve the permalink. A link to a referent is also stored. But the referent may be purged, so self.referent may be null. The serialized contextobject will still be there.
Class Method Summary collapse
-
.new_with_values!(rft, rfr_id) ⇒ Object
You should create Permalinks with this.
Instance Method Summary collapse
-
#restore_context_object ⇒ Object
Takes the XML stored in self.context_obj_serialized, and turns it back into an OpenURL ContextObject.
Class Method Details
.new_with_values!(rft, rfr_id) ⇒ Object
You should create Permalinks with this. Pass in a referent and referrer . Will save permalink to db
10 11 12 13 14 15 16 17 |
# File 'app/models/permalink.rb', line 10 def self.new_with_values!(rft, rfr_id) permalink = Permalink.new permalink.referent = rft permalink.orig_rfr_id = rfr_id permalink.context_obj_serialized = permalink.referent.to_context_object.xml permalink.save! return permalink end |
Instance Method Details
#restore_context_object ⇒ Object
Takes the XML stored in self.context_obj_serialized, and turns it back into an OpenURL ContextObject
21 22 23 |
# File 'app/models/permalink.rb', line 21 def restore_context_object return OpenURL::ContextObject.new_from_xml(self.context_obj_serialized) end |