Sha256: 301477446cb3c2c0a51c0a6c03928c3c521586c8103c035f6e70635f3464473a

Contents?: true

Size: 1.69 KB

Versions: 33

Compression:

Stored size: 1.69 KB

Contents

module ActiveFedora
  module Common
    extend ActiveSupport::Concern
    include Pathing

    module ClassMethods
      def initialize_generated_modules # :nodoc:
        generated_association_methods
      end

      def generated_association_methods
        @generated_association_methods ||= begin
          mod = const_set(:GeneratedAssociationMethods, Module.new)
          include mod
          mod
        end
      end
    end

    def ldp_source
      @ldp_source
    end

    # 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.
    def ==(other)
      other.equal?(self) ||
        (other.instance_of?(self.class) &&
          !id.nil? &&
          other.id == id)
    end

    # Allows sort on objects
    def <=>(other)
      if other.is_a?(self.class)
        to_key <=> other.to_key
      else
        super
      end
    end

    # Freeze datastreams such that they can be loaded from Fedora, but can't be changed
    def freeze
      @frozen = true
    end

    def frozen?
      @frozen.present?
    end

    # 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.
    def readonly?
      @readonly
    end

    # Marks this record as read only.
    def readonly!
      @readonly = true
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
active-fedora-11.2.1 lib/active_fedora/common.rb
active-fedora-11.3.1 lib/active_fedora/common.rb
active-fedora-11.3.0 lib/active_fedora/common.rb
active-fedora-11.2.0 lib/active_fedora/common.rb
active-fedora-11.1.6 lib/active_fedora/common.rb
active-fedora-11.1.5 lib/active_fedora/common.rb
active-fedora-11.1.4 lib/active_fedora/common.rb
active-fedora-11.1.3 lib/active_fedora/common.rb
active-fedora-11.1.2 lib/active_fedora/common.rb
active-fedora-11.1.1 lib/active_fedora/common.rb
active-fedora-11.1.0 lib/active_fedora/common.rb
active-fedora-10.3.0 lib/active_fedora/common.rb
active-fedora-11.0.1 lib/active_fedora/common.rb
active-fedora-11.0.0 lib/active_fedora/common.rb
active-fedora-10.3.0.rc2 lib/active_fedora/common.rb
active-fedora-11.0.0.rc7 lib/active_fedora/common.rb
active-fedora-10.3.0.rc1 lib/active_fedora/common.rb
active-fedora-11.0.0.rc6 lib/active_fedora/common.rb
active-fedora-10.2.1 lib/active_fedora/common.rb
active-fedora-11.0.0.rc5 lib/active_fedora/common.rb