Sha256: 89bdf070499610fe9c2fa1b1f9c669f2146345f5bc23bb9854c85e01b2fc7ea0

Contents?: true

Size: 971 Bytes

Versions: 32

Compression:

Stored size: 971 Bytes

Contents

# 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 Permalink < ActiveRecord::Base
  belongs_to :referent

  # You should create Permalinks with this. Pass in a referent and referrer
  #. Will save  permalink to db
  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


  # Takes the XML stored in self.context_obj_serialized, and turns it back
  # into an OpenURL ContextObject
  def restore_context_object
    return OpenURL::ContextObject.new_from_xml(self.context_obj_serialized)
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
umlaut-3.0.0alpha12 app/models/permalink.rb
umlaut-3.0.0alpha11 app/models/permalink.rb
umlaut-3.0.0alpha10 app/models/permalink.rb
umlaut-3.0.0alpha9 app/models/permalink.rb
umlaut-3.0.0alpha8 app/models/permalink.rb
umlaut-3.0.0alpha7 app/models/permalink.rb
umlaut-3.0.0alpha6 app/models/permalink.rb
umlaut-3.0.0alpha5 app/models/permalink.rb
umlaut-3.0.0alpha4 app/models/permalink.rb
umlaut-3.0.0alpha3 app/models/permalink.rb
umlaut-3.0.0alpha2 app/models/permalink.rb
umlaut-3.0.0alpha1 app/models/permalink.rb