Sha256: 681f0a4067ab82f51d8989187bd78998ac58968508b8ccba50659aae5432695d

Contents?: true

Size: 1.56 KB

Versions: 20

Compression:

Stored size: 1.56 KB

Contents

ActiveFedora::Base.class_eval do

    def can_have_attachments?
      has_association? :attachments
    end

    def has_attachments?
      can_have_attachments? && attachments.size > 0
    end

    def can_have_children?
      has_association? :children
    end

    def has_children?
      can_have_children? and children.size > 0
    end

    def can_have_content?
      attached_files.key? "content"
    end

    def has_content?
      can_have_content? && content.has_content?
    end

    def describable?
      self.is_a? Ddr::Models::Base
    end
    deprecation_deprecate :describable?

    def governable?
      has_association? :admin_policy
    end

    def has_admin_policy?
      governable? && admin_policy.present?
    end

    def can_have_struct_metadata?
      attached_files.key? Ddr::Models::File::STRUCT_METADATA
    end

    def has_struct_metadata?
      can_have_struct_metadata? && structMetadata.has_content?
    end

    def can_have_multires_image?
      respond_to? :multires_image_file_path
    end

    def has_multires_image?
      can_have_multires_image? && multires_image_file_path.present?
    end

    def can_have_thumbnail?
      attached_files.key? "thumbnail"
    end

    def has_thumbnail?
      can_have_thumbnail? && thumbnail.has_content?
    end

    def safe_id
      id.sub(/:/, "-")
    end

    # For duck-typing with SolrDocument
    def active_fedora_model
      self.class.to_s
    end

    def controller_name
      active_fedora_model.tableize
    end

    protected

    def has_association? assoc
      !association(assoc).nil?
    end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ddr-models-3.0.8 config/initializers/active_fedora_base.rb
ddr-models-3.0.7 config/initializers/active_fedora_base.rb
ddr-models-3.0.6 config/initializers/active_fedora_base.rb
ddr-models-3.0.5 config/initializers/active_fedora_base.rb
ddr-models-3.0.4 config/initializers/active_fedora_base.rb
ddr-models-3.0.3 config/initializers/active_fedora_base.rb
ddr-models-3.0.2 config/initializers/active_fedora_base.rb
ddr-models-3.0.1 config/initializers/active_fedora_base.rb
ddr-models-3.0.0 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.rc6 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.rc5 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.rc4 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.rc3 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.rc2 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.rc1 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.beta.22 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.beta.21 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.beta.20 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.beta.18 config/initializers/active_fedora_base.rb
ddr-models-3.0.0.beta.17 config/initializers/active_fedora_base.rb