Module: ActiveFedora::Common
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Allows sort on objects.
-
#==(other) ⇒ Object
Returns true if
comparison_object
is the same exact object, orcomparison_object
is of the same type andself
has an ID and it is equal tocomparison_object.id
. -
#freeze ⇒ Object
Freeze datastreams such that they can be loaded from Fedora, but can’t be changed.
- #frozen? ⇒ Boolean
- #ldp_source ⇒ Object
-
#readonly! ⇒ Object
Marks this record as read only.
-
#readonly? ⇒ Boolean
Returns
true
if the record is read only.
Instance Method Details
#<=>(other) ⇒ Object
Allows sort on objects
39 40 41 42 43 44 45 |
# File 'lib/active_fedora/common.rb', line 39 def <=>(other) if other.is_a?(self.class) to_key <=> other.to_key else super end end |
#==(other) ⇒ Object
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.
31 32 33 34 35 36 |
# File 'lib/active_fedora/common.rb', line 31 def ==(other) other.equal?(self) || (other.instance_of?(self.class) && !id.nil? && other.id == id) end |
#freeze ⇒ Object
Freeze datastreams such that they can be loaded from Fedora, but can’t be changed
48 49 50 |
# File 'lib/active_fedora/common.rb', line 48 def freeze @frozen = true end |
#frozen? ⇒ Boolean
52 53 54 |
# File 'lib/active_fedora/common.rb', line 52 def frozen? @frozen.present? end |
#ldp_source ⇒ Object
19 20 21 |
# File 'lib/active_fedora/common.rb', line 19 def ldp_source @ldp_source end |
#readonly! ⇒ Object
Marks this record as read only.
63 64 65 |
# File 'lib/active_fedora/common.rb', line 63 def readonly! @readonly = true end |
#readonly? ⇒ Boolean
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.
58 59 60 |
# File 'lib/active_fedora/common.rb', line 58 def readonly? @readonly end |