Sha256: 57b82907f9e817073ce19edcd8a08072c92696c22b20b6d414fcaef84f885320

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

ActiveFedora::Base.class_eval do

  delegate :object_xml, :models, :to => :inner_object

  def safe_pid
    pid.sub(/:/, "-")
  end

  def active?
    state == 'A'
  end

  def auditable?
    begin
      self.is_a? ActiveFedora::Auditable
    rescue
      false
    end
  end

  def has_permissions?
    self.is_a? Hydra::ModelMixins::RightsMetadata
  end

  def governable?
    !governed_by_association.nil?
  end

  def governed_by_association
    self.reflections.each do |name, reflection|
      # FIXME add class name condition, i.e.:
      # && reflection.class_name == [Hydra configured policy class or Hydra::AdminPolicy]
      return reflection if reflection.macro == :belongs_to && reflection.options[:property] == :is_governed_by
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fcrepo_admin-0.6.1 lib/fcrepo_admin/decorators/active_fedora/base_decorator.rb