Sha256: 42829b5cd18914cdb52b0674d79ac7de9fe6267166a419a503cadb1d5623ca91

Contents?: true

Size: 1.29 KB

Versions: 65

Compression:

Stored size: 1.29 KB

Contents

module Ddr
  module Models
    module Governable
      extend ActiveSupport::Concern

      included do
        belongs_to :admin_policy, :property => :is_governed_by, :class_name => "Collection"
      end

      def inherited_permissions
        admin_policy ? admin_policy.default_permissions : []
      end

      def inherited_rights
        admin_policy.datastreams[Ddr::Datastreams::DEFAULT_RIGHTS] if admin_policy
      end

      # Creates convenience methods:
      # inherited_discover_users, inherited_discover_groups,
      # inherited_read_users, inherited_read_groups,
      # inherited_edit_user, inherited_edit_groups
      ["discover", "read", "edit"].each do |access|
        ["user", "group"].each do |type|
          define_method("inherited_#{access}_#{type}s") do
            admin_policy ? admin_policy.send("default_#{access}_#{type}s") : []
          end
        end
      end

      def copy_admin_policy_from(other)
        # XXX In active-fedora 7.0 can do
        # self.admin_policy = other.admin_policy
        self.admin_policy_id = case
        when other.has_admin_policy?
          other.admin_policy_id
        when other.is_a?(Collection)
          other.pid
        end
        # self.admin_policy_id = other.admin_policy_id if other.has_admin_policy?
      end

    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
ddr-models-2.4.8 lib/ddr/models/governable.rb
ddr-models-2.4.7 lib/ddr/models/governable.rb
ddr-models-2.4.6 lib/ddr/models/governable.rb
ddr-models-2.4.5 lib/ddr/models/governable.rb
ddr-models-2.4.4 lib/ddr/models/governable.rb
ddr-models-2.4.3 lib/ddr/models/governable.rb
ddr-models-2.4.2 lib/ddr/models/governable.rb
ddr-models-2.4.1 lib/ddr/models/governable.rb
ddr-models-2.4.0 lib/ddr/models/governable.rb
ddr-models-2.4.0.rc6 lib/ddr/models/governable.rb
ddr-models-2.4.0.rc5 lib/ddr/models/governable.rb
ddr-models-2.4.0.rc4 lib/ddr/models/governable.rb
ddr-models-2.4.0.rc3 lib/ddr/models/governable.rb
ddr-models-2.4.0.rc2 lib/ddr/models/governable.rb
ddr-models-2.4.0.rc1 lib/ddr/models/governable.rb
ddr-models-2.3.2 lib/ddr/models/governable.rb
ddr-models-2.3.1 lib/ddr/models/governable.rb
ddr-models-2.3.0 lib/ddr/models/governable.rb
ddr-models-2.2.0 lib/ddr/models/governable.rb
ddr-models-2.1.3 lib/ddr/models/governable.rb