Module: ActiveFedora::RelationshipsHelper

Includes:
MediaShelfClassLevelInheritableAttributes
Defined in:
lib/active_fedora/relationships_helper.rb

Overview

This module is meant to extend semantic node to add functionality based on a relationship’s name It is meant to turn a relationship into just another attribute in a model. The notion of a “relationship name” is used internally to distinguish between the relationships you’ve set up using has_relationship and the implicit relationships that are based on the predicates themselves.

Examples:

ActiveFedora

has_relationship "parents", :is_member_of

obj.parents is a relationship in ActiveFedora while :is_member_of is the literal RDF relationship in Fedora

There are also several helper methods created for any relationship declared in ActiveFedora.  For the above example
the following methods are created:

obj.parents_append(object)  Appends an object to the "parents" relationship
obj.parents_remove(object)  Removes an object from the "parents" relationship
obj.parents_query           Returns the query used against solr to retrieve objects linked via the "parents" relationship

Note: ActiveFedora relationships can reflect filters ...
If you define the solr_fq parameter in your has_relationship call some objects will be filtered out:

has_relationship "parents", :is_member_of, :solr_fq=>"eyes:blue"

Then obj.parents will only return parents where their eyes are blue.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



29
30
31
# File 'lib/active_fedora/relationships_helper.rb', line 29

def self.included(klass)
  klass.extend(ClassMethods)
end

Instance Method Details

#add_named_relationship(name, object) ⇒ Object

Deprecated.

Please use #add_relationship_by_name instead.



520
521
522
523
# File 'lib/active_fedora/relationships_helper.rb', line 520

def add_named_relationship(name,object)
  logger.warn("Deprecation: add_named_relationship has been deprecated.  Please call add_relationship_by_name instead.")
  add_relationship_by_name(name,object)
end

#add_relationship_by_name(name, object) ⇒ Boolean

** EXPERIMENTAL **

Add an outbound relationship for given relationship name See ActiveFedora::SemanticNode::ClassMethods.has_relationship

Parameters:

  • Name (String)

    of relationship

  • object (ActiveFedora::Base)

    to add to the relationship (expects ActvieFedora::Base to be an ancestor)

Returns:

  • (Boolean)

    returns true if add operation successful



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/active_fedora/relationships_helper.rb', line 270

def add_relationship_by_name(name, object)
  if is_relationship_name?(name,true)
    if relationships_desc[:self][name].has_key?(:type)
      klass = class_from_name(relationships_desc[:self][name][:type])
      unless klass.nil?
        (assert_conforms_to 'object', object, klass)
      end
    end
    #r = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>outbound_relationship_predicates[name],:object=>object})
    #add_relationship(r)
    add_relationship(outbound_relationship_predicates[name],object)
  else
    false
  end
end

#assert_conforms_to(name, object, model_class) ⇒ Object

** EXPERIMENTAL **

Throws an assertion error if conforms_to? returns false for object and model_class

Parameters:

  • Name (String)

    of object (just label for output)

  • Expects (ActiveFedora::Base)

    to be an object that has ActiveFedora::Base as an ancestor of its class

  • The (Class)

    model class used in conforms_to? check on object



306
307
308
# File 'lib/active_fedora/relationships_helper.rb', line 306

def assert_conforms_to(name, object, model_class)
  raise "Assertion failure: #{name}: #{object.pid} does not have model #{model_class}, it has model #{relationships[:self][:has_model]}" unless object.conforms_to?(model_class)
end

#assert_kind_of_model(name, object, model_class) ⇒ Object

Deprecated.

Please use #assert_conforms_to instead.



532
533
534
535
# File 'lib/active_fedora/relationships_helper.rb', line 532

def assert_kind_of_model(name,object,model_class)
  logger.warn("Deprecation: assert_kind_of_model has been deprecated.  Please call assert_conforms_to instead.")
  assert_conforms_to(name,object,model_class)
end

#class_from_name(name) ⇒ Class

Returns a Class symbol for the given string for the class name

Parameters:

  • the (String)

    class name as a string

Returns:

  • (Class)

    the class as a Class object



342
343
344
345
346
# File 'lib/active_fedora/relationships_helper.rb', line 342

def class_from_name(name)
  klass = name.to_s.split('::').inject(Kernel) {|scope, const_name| 
  scope.const_get(const_name)}
  (!klass.nil? && klass.is_a?(::Class)) ? klass : nil
end

#conforms_to?(model_class) ⇒ Boolean

** EXPERIMENTAL **

Checks that this object is matches the model class passed in. It requires two steps to pass to return true

1. It has a hasModel relationship of the same model
2. kind_of? returns true for the model passed in

This method can most often be used to detect if an object from Fedora that was created with a different model was then used to populate this object.

Parameters:

  • the (Class)

    model class name to check if an object conforms_to that model

Returns:

  • (Boolean)

    true if this object conforms to the given model name



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/active_fedora/relationships_helper.rb', line 320

def conforms_to?(model_class)
  if self.kind_of?(model_class)
    #check has model and class match
    if relationships[:self].has_key?(:has_model)
      r = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>:has_model, :object=>ActiveFedora::ContentModel.pid_from_ruby_class(self.class))
      if relationships[:self][:has_model].first.to_s.eql?(r.object.to_s)
        return true
      else
        raise "has_model relationship check failed for model #{model_class} raising exception, expected: '#{r.object.to_s}' actual: '#{relationships[:self][:has_model].to_s}'"
      end
    else
      raise "has_model relationship does not exist for model #{model_class} check raising exception"
    end
  else
    raise "kind_of? check failed for model #{model_class}, actual #{self.class} raising exception"
  end
  return false
end

#find_relationship_by_name(name) ⇒ Array

** EXPERIMENTAL **

Return array of objects for a given relationship name

Parameters:

  • Name (String)

    of relationship to find

Returns:

  • (Array)

    Returns array of objects linked via the relationship name given



39
40
41
42
43
44
45
46
47
48
# File 'lib/active_fedora/relationships_helper.rb', line 39

def find_relationship_by_name(name)
  rels = nil
  if inbound_relationship_names.include?(name)
    rels = relationships_by_name(false)[:inbound][name]
  elsif outbound_relationship_names.include?(name)
    rels = relationships_by_name[:self][name]
  end
  rels = [] if rels.nil?
  return rels
end

#inbound_named_relationship_predicatesObject

Deprecated.

Please use #inbound_relationship_predicates instead.



478
479
480
481
# File 'lib/active_fedora/relationships_helper.rb', line 478

def inbound_named_relationship_predicates
  logger.warn("Deprecation: inbound_named_relationship_predicates has been deprecated.  Please call inbound_relationship_predicates instead.")
  inbound_relationship_predicates
end

#inbound_relationship_namesArray

** EXPERIMENTAL **

Return array of relationship names for all inbound relationships (coming from other objects’ RELS-EXT and Solr)

Returns:

  • (Array)

    of inbound relationship names for relationships declared via has_relationship in the class



192
193
194
# File 'lib/active_fedora/relationships_helper.rb', line 192

def inbound_relationship_names
    relationships_desc.has_key?(:inbound) ? relationships_desc[:inbound].keys : []
end

#inbound_relationship_predicatesHash

** EXPERIMENTAL **

Return hash of inbound relationship names and predicate pairs

Returns:

  • (Hash)

    A hash of inbound relationship names mapped to predicates used



146
147
148
# File 'lib/active_fedora/relationships_helper.rb', line 146

def inbound_relationship_predicates
  relationship_predicates.has_key?(:inbound) ? relationship_predicates[:inbound] : {}
end

#inbound_relationships_by_nameHash

** EXPERIMENTAL **

Return hash of relationships_by_name defined within other objects’ RELS-EXT It returns a hash of relationship name to arrays of objects. It requeries solr each time this method is called.

Returns:

  • (Hash)

    Return hash of each relationship name mapped to an Array of objects linked to this object via inbound relationships



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/active_fedora/relationships_helper.rb', line 120

def inbound_relationships_by_name
  rels = {}
  if relationships_desc.has_key?(:inbound)&&!relationships_desc[:inbound].empty?()
    inbound_rels = inbound_relationships
  
    if relationship_predicates.has_key?(:inbound)
      relationship_predicates[:inbound].each do |name, predicate|
        rels[name] = inbound_rels.has_key?(predicate) ? inbound_rels[predicate] : []
      end
    end
  end
  return rels
end

#is_named_relationship?(name, outbound_only = true) ⇒ Boolean

Deprecated.

Please use #is_relationship_name? instead.

Returns:

  • (Boolean)


496
497
498
499
# File 'lib/active_fedora/relationships_helper.rb', line 496

def is_named_relationship?(name, outbound_only=true)
  logger.warn("Deprecation: is_named_relationship? has been deprecated.  Please call is_relationship_name? instead.")
  is_relationship_name?(name,outbound_only)
end

#is_relationship_name?(name, outbound_only = true) ⇒ Boolean

** EXPERIMENTAL **

Returns true if the given relationship name is a relationship

Parameters:

  • Name (String)

    of relationship

  • If (Boolean)

    false checks inbound relationships as well (defaults to true)

Returns:

  • (Boolean)


218
219
220
221
222
223
224
# File 'lib/active_fedora/relationships_helper.rb', line 218

def is_relationship_name?(name, outbound_only=true)
  if outbound_only
    outbound_relationship_names.include?(name)
  else
    (outbound_relationship_names.include?(name)||inbound_relationship_names.include?(name))
  end
end

#kind_of_model?(model_class) ⇒ Boolean

Deprecated.

Please use #conforms_to? instead.

Returns:

  • (Boolean)


538
539
540
541
# File 'lib/active_fedora/relationships_helper.rb', line 538

def kind_of_model?(model_class)
  logger.warn("Deprecation: kind_of_model? has been deprecated.  Please call conforms_to? instead.")
  conforms_to?(model_class)
end

#named_inbound_relationshipsObject

Deprecated.

Please use #inbound_relationships_by_name instead.



460
461
462
463
# File 'lib/active_fedora/relationships_helper.rb', line 460

def named_inbound_relationships
  logger.warn("Deprecation: named_inbound_relationships has been deprecated.  Please call inbound_relationships_by_name instead.")
  inbound_relationships_by_name
end

#named_outbound_relationshipsObject

Deprecated.

Please use #outbound_relationships_by_name instead.



466
467
468
469
# File 'lib/active_fedora/relationships_helper.rb', line 466

def named_outbound_relationships
  logger.warn("Deprecation: named_outbound_relationships has been deprecated.  Please call outbound_relationships_by_name instead.")
  outbound_relationships_by_name
end

#named_relationship(name) ⇒ Object

Deprecated.

Please use #find_relationship_by_name instead.



430
431
432
433
# File 'lib/active_fedora/relationships_helper.rb', line 430

def named_relationship(name)
  logger.warn("Deprecation: named_relationship has been deprecated.  Please call find_relationship_by_name instead.")
  find_relationship_by_name(name)
end

#named_relationship_predicatesObject

Deprecated.

Please use #relationship_predicates instead.



484
485
486
487
# File 'lib/active_fedora/relationships_helper.rb', line 484

def named_relationship_predicates
  logger.warn("Deprecation: named_relationship_predicates has been deprecated.  Please call relationship_predicates instead.")
  relationship_predicates
end

#named_relationship_predicates_from_classObject

Deprecated.


490
491
492
493
# File 'lib/active_fedora/relationships_helper.rb', line 490

def named_relationship_predicates_from_class
  logger.warn("Deprecation: named_relationship_predicates_from_class has been deprecated.  Please call relationship_predicates_from_class instead.")
  relationship_predicates_from_class
end

#named_relationship_query(relationship_name) ⇒ Object

Deprecated.

Please use #relationship_query instead.



544
545
546
547
# File 'lib/active_fedora/relationships_helper.rb', line 544

def named_relationship_query(relationship_name)
  logger.warn("Deprecation: named_relationship_query has been deprecated.  Please call relationship_query instead.")
  relationship_query(relationship_name)
end

#named_relationship_type(name) ⇒ Object

Deprecated.

Please use #relationship_model_type instead.



514
515
516
517
# File 'lib/active_fedora/relationships_helper.rb', line 514

def named_relationship_type(name)
  logger.warn("Deprecation: named_relationship_type has been deprecated.  Please call relationship_model_type instead.")
  relationship_model_type(name)
end

#named_relationships(outbound_only = true) ⇒ Object

Deprecated.

Please use #relationships_by_name instead.



448
449
450
451
# File 'lib/active_fedora/relationships_helper.rb', line 448

def named_relationships(outbound_only=true)
  logger.warn("Deprecation: named_relationships has been deprecated.  Please call relationships_by_name instead.")
  relationships_by_name(outbound_only)
end

#named_relationships_descObject

Deprecated.

Please use #relationships_desc instead.



502
503
504
505
# File 'lib/active_fedora/relationships_helper.rb', line 502

def named_relationships_desc
  logger.warn("Deprecation: named_relationships_desc has been deprecated.  Please call relationships_desc instead.")
  relationships_desc
end

#named_relationships_desc_from_classObject

Deprecated.

Please use #relationships_desc_from_class instead.



508
509
510
511
# File 'lib/active_fedora/relationships_helper.rb', line 508

def named_relationships_desc_from_class
  logger.warn("Deprecation: named_relationships_desc_from_class has been deprecated.  Please call relationships_desc_from_class instead.")
  relationships_desc_from_class
end

#named_relationships_from_classObject

Deprecated.

Please use #relationships_by_name_from_class instead.



454
455
456
457
# File 'lib/active_fedora/relationships_helper.rb', line 454

def named_relationships_from_class
  logger.warn("Deprecation: named_relationships_from_class has been deprecated.  Please call relationships_by_name_from_class instead.")
  relationships_by_name_from_class
end

#outbound_named_relationship_predicatesObject

Deprecated.

Please use #outbound_relationship_predicates instead.



472
473
474
475
# File 'lib/active_fedora/relationships_helper.rb', line 472

def outbound_named_relationship_predicates
  logger.warn("Deprecation: outbound_named_relationship_predicates has been deprecated.  Please call outbound_relationship_predicates instead.")
  outbound_relationship_predicates
end

#outbound_relationship_namesArray

** EXPERIMENTAL **

Return array of relationship names for all outbound relationships (coming from this object’s RELS-EXT)

Returns:

  • (Array)

    of outbound relationship names for relationships declared via has_relationship in the class



200
201
202
# File 'lib/active_fedora/relationships_helper.rb', line 200

def outbound_relationship_names
    relationships_desc.has_key?(:self) ? relationships_desc[:self].keys : []
end

#outbound_relationship_predicatesHash

** EXPERIMENTAL **

Return hash of outbound relationship names and predicate pairs

Returns:

  • (Hash)

    A hash of outbound relationship names mapped to predicates used



138
139
140
# File 'lib/active_fedora/relationships_helper.rb', line 138

def outbound_relationship_predicates
  relationship_predicates.has_key?(:self) ? relationship_predicates[:self] : {}
end

#outbound_relationships_by_nameHash

** EXPERIMENTAL **

Return hash of relationships_by_name defined within this object’s RELS-EXT It returns a hash of relationship name to arrays of objects

Returns:

  • (Hash)

    Return hash of each relationship name mapped to an Array of objects linked to this object via outbound relationships



209
210
211
# File 'lib/active_fedora/relationships_helper.rb', line 209

def outbound_relationships_by_name
    relationships_desc.has_key?(:self) ? relationships_by_name[:self] : {}
end

#register_named_relationship(subject, name, predicate, opts) ⇒ Object

Deprecated.

Please use #register_relationship_desc instead.



442
443
444
445
# File 'lib/active_fedora/relationships_helper.rb', line 442

def register_named_relationship(subject, name, predicate, opts)
  logger.warn("Deprecation: register_named_relationship has been deprecated.  Please call register_relationship_desc instead.")
  register_relationship_desc(subject, name, predicate, opts)
end

#register_named_subject(subject) ⇒ Object

Deprecated.


436
437
438
439
# File 'lib/active_fedora/relationships_helper.rb', line 436

def register_named_subject(subject)
  logger.warn("Deprecation: register_named_subject has been deprecated.  Please call register_relationship_desc_subject instead.")
  register_relationship_desc_subject(subject)
end

#register_relationship_desc(subject, name, predicate, opts = {}) ⇒ Object

** EXPERIMENTAL **

Internal method that adds a relationship description for a relationship name and predicate pair to either an outbound (:self) or inbound (:inbound) relationship types. This method just calls the class method counterpart of this method.

Parameters:

  • Subject (Symbol)

    name to register

  • Name (String)

    of relationship being registered

  • Fedora (Symbol)

    ontology predicate to use

  • Any (Hash)

    options passed to has_relationship such as :type, :solr_fq, etc.



69
70
71
# File 'lib/active_fedora/relationships_helper.rb', line 69

def register_relationship_desc(subject, name, predicate, opts={})
  self.class.register_relationship_desc(subject, name, predicate, opts)
end

#register_relationship_desc_subject(subject) ⇒ Object

Internal method that ensures a relationship subject such as :self and :inbound exist within the relationships_desc hash tracking relationships metadata. This method just calls the class method counterpart of this method.

Parameters:

  • Subject (Symbol)

    name to register (will probably be something like :self or :inbound)



56
57
58
# File 'lib/active_fedora/relationships_helper.rb', line 56

def register_relationship_desc_subject(subject)
  self.class.register_relationship_desc_subject(subject)
end

#relationship_model_type(name) ⇒ Class

** EXPERIMENTAL **

Return the value of :type for the relationship for name passed in if defined It defaults to ActiveFedora::Base.

Returns:

  • (Class)

    the name of the class defined for a relationship by the :type option if present



253
254
255
256
257
258
259
260
261
# File 'lib/active_fedora/relationships_helper.rb', line 253

def relationship_model_type(name)
  if is_relationship_name?(name,true)
    subject = outbound_relationship_names.include?(name)? :self : :inbound
    if relationships_desc[subject][name].has_key?(:type)
      return class_from_name(relationships_desc[subject][name][:type])
    end
  end
  return nil  
end

#relationship_namesArray

** EXPERIMENTAL **

Return array all relationship names

Returns:

  • (Array)

    of relationship names for relationships declared via has_relationship in the class



180
181
182
183
184
185
186
# File 'lib/active_fedora/relationships_helper.rb', line 180

def relationship_names
  names = []
  relationships_desc.each_key do |subject|
        names = names.concat(relationships_desc[subject].keys)
    end
    names
end

#relationship_predicatesHash

** EXPERIMENTAL **

Return hash of relationship names and predicate pairs (inbound and outbound). This method calls the class method version of this method to get the static settings defined in the class definition.

Returns:

  • (Hash)

    A hash of relationship names (inbound and outbound) mapped to predicates used



156
157
158
# File 'lib/active_fedora/relationships_helper.rb', line 156

def relationship_predicates
  @relationship_predicates ||= relationship_predicates_from_class
end

#relationship_predicates_from_classHash

** EXPERIMENTAL **

Return hash of relationship names and predicate pairs from class. It retrieves this information via the relationships_desc hash in the class.

Returns:

  • (Hash)

    A hash of relationship names (inbound and outbound) mapped to predicates used



165
166
167
168
169
170
171
172
173
174
# File 'lib/active_fedora/relationships_helper.rb', line 165

def relationship_predicates_from_class
  rels = {}
  relationships_desc.each_pair do |subj, names|
    rels[subj] = {}
    names.each_pair do |name, args|
      rels[subj][name] = args[:predicate]
    end
  end
  return rels
end

#relationship_query(relationship_name) ⇒ String

Call this method to return the query used against solr to retrieve any objects linked via the relationship name given.

Instead of this method you can also use the helper method [relationship_name]_query, i.e. method “parts_query” for relationship “parts” to return the same value

Examples:

Class SampleAFObjRelationshipFilterQuery < ActiveFedora::Base
  #points to all parents linked via is_member_of
  has_relationship "parents", :is_member_of
  #returns only parents that have a level value set to "series"
  has_relationship "series_parents", :is_member_of, :solr_fq=>level_t:series"
end
s = SampleAFObjRelationshipFilterQuery.new
obj = ActiveFedora::Base.new
s.parents_append(obj)
s.series_parents_query 
#=> "(id:changeme\\:13020 AND level_t:series)" 
SampleAFObjRelationshipFilterQuery.relationship_query("series_parents")
#=> "(id:changeme\\:13020 AND level_t:series)" 

Parameters:

  • The (String)

    name of the relationship defined in the model

Returns:

  • (String)

    The query used when querying solr for objects for this relationship



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/active_fedora/relationships_helper.rb', line 369

def relationship_query(relationship_name)
  query = ""
  if self.class.is_bidirectional_relationship?(relationship_name)
    id_array = []
    predicate = outbound_relationship_predicates["#{relationship_name}_outbound"]
    if !outbound_relationships[predicate].nil? 
      outbound_relationships[predicate].each do |rel|
        id_array << rel.gsub("info:fedora/", "")
      end
    end
    query = self.class.bidirectional_relationship_query(pid,relationship_name,id_array)
  elsif outbound_relationship_names.include?(relationship_name)
    id_array = []
    predicate = outbound_relationship_predicates[relationship_name]
    if !outbound_relationships[predicate].nil? 
      outbound_relationships[predicate].each do |rel|
        id_array << rel.gsub("info:fedora/", "")
      end
    end
    query = self.class.outbound_relationship_query(relationship_name,id_array)
  elsif inbound_relationship_names.include?(relationship_name)
    query = self.class.inbound_relationship_query(pid,relationship_name)
  end
  query
end

#relationships_by_name(outbound_only = true) ⇒ Hash

** EXPERIMENTAL **

Gets the relationships hash with subject mapped to relationship names instead of relationship predicates (unlike the “relationships” method in SemanticNode) It has an optional parameter of outbound_only that defaults true. If false it will include inbound relationships in the results. Also, it will only reload outbound relationships if the relationships hash has changed since the last time this method was called.

Parameters:

  • if (Boolean)

    false it will include inbound relationships (defaults to true)

Returns:

  • (Hash)

    Returns a hash of subject name (:self or :inbound) mapped to nested hashs of each relationship name mapped to an Array of objects linked via the relationship



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/active_fedora/relationships_helper.rb', line 83

def relationships_by_name(outbound_only=true)
  #make sure to update if relationships have been updated
  if @relationships_are_dirty == true
    @relationships_by_name = relationships_by_name_from_class()
    @relationships_are_dirty = false
  end
  
  #this will get called normally on first fetch if relationships are not dirty
  @relationships_by_name ||= relationships_by_name_from_class()
  outbound_only ? @relationships_by_name : @relationships_by_name.merge(:inbound=>inbound_relationships_by_name)      
end

#relationships_by_name_from_classHash

** EXPERIMENTAL **

Gets relationships by name from the class using the current relationships hash and relationship name,predicate pairs.

Returns:

  • (Hash)

    returns the outbound relationships with :self mapped to nested hashs of each relationship name mapped to an Array of objects linked via the relationship



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/active_fedora/relationships_helper.rb', line 100

def relationships_by_name_from_class()
  rels = {}
  relationship_predicates.each_pair do |subj, names|
    if relationships.has_key?(subj)
      rels[subj] = {}
      names.each_pair do |name, predicate|
        rels[subj][name] = (relationships[subj].has_key?(predicate) ? relationships[subj][predicate] : [])
      end
    end
  end
  return rels
end

#relationships_descHash

** EXPERIMENTAL **

Return hash that persists relationship metadata defined by has_relationship calls

Examples:

For the following relationship


has_relationship "audio_records", :has_part, :type=>AudioRecord

Results in the following returned by relationships_desc
{:self=>{"audio_records"=>{:type=>AudioRecord, :singular=>nil, :predicate=>:has_part, :inbound=>false}}}

Returns:

  • (Hash)

    Hash of relationship subject (:self or :inbound) mapped to nested hashs of each relationship name mapped to another hash relationship options



236
237
238
# File 'lib/active_fedora/relationships_helper.rb', line 236

def relationships_desc
  @relationships_desc ||= relationships_desc_from_class
end

#relationships_desc_from_classHash

** EXPERIMENTAL **

Get class instance variable relationships_desc that holds has_relationship metadata

Returns:

  • (Hash)

    Hash of relationship subject (:self or :inbound) mapped to nested hashs of each relationship name mapped to another hash relationship options



244
245
246
# File 'lib/active_fedora/relationships_helper.rb', line 244

def relationships_desc_from_class
  self.class.relationships_desc
end

#remove_named_relationship(name, object) ⇒ Object

Deprecated.

Please use #remove_relationship_by_name instead.



526
527
528
529
# File 'lib/active_fedora/relationships_helper.rb', line 526

def remove_named_relationship(name,object)
  logger.warn("Deprecation: remove_named_relationship has been deprecated.  Please call remove_relationship_by_name instead.")
  remove_relationship_by_name(name,object)
end

#remove_relationship_by_name(name, object) ⇒ Boolean

** EXPERIMENTAL **

Remove an object for the given relationship name

Parameters:

Returns:

  • (Boolean)

    return true if remove operation successful



292
293
294
295
296
297
298
# File 'lib/active_fedora/relationships_helper.rb', line 292

def remove_relationship_by_name(name, object)
  if is_relationship_name?(name,true)
    remove_relationship(outbound_relationship_predicates[name],object)
  else
    return false
  end
end