Sha256: 454e94a8054bbee16aff2be4e88fd9c94458a7f71a97b247de3dcf82284999dd

Contents?: true

Size: 948 Bytes

Versions: 27

Compression:

Stored size: 948 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

27 entries across 27 versions & 1 rubygems

Version Path
umlaut-4.1.7 app/models/permalink.rb
umlaut-4.1.6 app/models/permalink.rb
umlaut-4.1.5 app/models/permalink.rb
umlaut-4.1.4 app/models/permalink.rb
umlaut-4.1.3 app/models/permalink.rb
umlaut-4.1.2 app/models/permalink.rb
umlaut-4.1.1 app/models/permalink.rb
umlaut-4.1.0 app/models/permalink.rb
umlaut-4.1.0.pre3 app/models/permalink.rb
umlaut-4.1.0.pre.2 app/models/permalink.rb
umlaut-4.1.0.pre.alpha.1 app/models/permalink.rb
umlaut-4.0.3 app/models/permalink.rb
umlaut-4.0.2 app/models/permalink.rb
umlaut-4.0.1 app/models/permalink.rb
umlaut-4.0.0 app/models/permalink.rb
umlaut-4.0.0.beta5 app/models/permalink.rb
umlaut-4.0.0.beta4 app/models/permalink.rb
umlaut-4.0.0.beta3 app/models/permalink.rb
umlaut-4.0.0.beta2 app/models/permalink.rb
umlaut-4.0.0.beta1 app/models/permalink.rb