module ActiveFedora::Common

Public Instance Methods

<=>(other) click to toggle source

Allows sort on objects

Calls superclass method
# File lib/active_fedora/common.rb, line 50
def <=>(other)
  if other.is_a?(self.class)
    to_key <=> other.to_key
  else
    super
  end
end
==(other) click to toggle source

Returns true if comparison_object is the same exact object, or comparison_object is of the same type and self has an ID and it is equal to comparison_object.id.

Note that new records are different from any other record by definition, unless the other record is the receiver itself.

Note also that destroying a record preserves its ID in the model instance, so deleted models are still comparable.

# File lib/active_fedora/common.rb, line 42
def ==(other)
  other.equal?(self) ||
    (other.instance_of?(self.class) &&
      !id.nil? &&
      other.id == id)
end
etag() click to toggle source

@return [String] the etag from the response headers

@raise [RuntimeError] when the resource is new and has no etag @raise [Ldp::Gone] when the resource is deleted

# File lib/active_fedora/common.rb, line 25
def etag
  raise 'Unable to produce an etag for a unsaved object' if ldp_source.new?
  ldp_source.head.etag
end
freeze() click to toggle source

Freeze datastreams such that they can be loaded from Fedora, but can’t be changed

# File lib/active_fedora/common.rb, line 59
def freeze
  @frozen = true
end
frozen?() click to toggle source
# File lib/active_fedora/common.rb, line 63
def frozen?
  @frozen.present?
end
ldp_source() click to toggle source
# File lib/active_fedora/common.rb, line 30
def ldp_source
  @ldp_source
end
readonly!() click to toggle source

Marks this record as read only.

# File lib/active_fedora/common.rb, line 74
def readonly!
  @readonly = true
end
readonly?() click to toggle source

Returns true if the record is read only. Records loaded through joins with piggy-back attributes will be marked as read only since they cannot be saved.

# File lib/active_fedora/common.rb, line 69
def readonly?
  @readonly
end