Module: ActiveFedora::RelationshipsHelper

Extended by:
ActiveSupport::Concern
Included in:
Base
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

Instance Method Summary collapse

Instance Method Details

#add_named_relationship(name, object) ⇒ Object

Deprecated.

Please use #add_relationship_by_name instead.



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

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



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/active_fedora/relationships_helper.rb', line 275

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



311
312
313
# File 'lib/active_fedora/relationships_helper.rb', line 311

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.



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

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



347
348
349
350
351
# File 'lib/active_fedora/relationships_helper.rb', line 347

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



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/active_fedora/relationships_helper.rb', line 325

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



44
45
46
47
48
49
50
51
52
53
# File 'lib/active_fedora/relationships_helper.rb', line 44

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.



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

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



197
198
199
# File 'lib/active_fedora/relationships_helper.rb', line 197

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



151
152
153
# File 'lib/active_fedora/relationships_helper.rb', line 151

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



125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/active_fedora/relationships_helper.rb', line 125

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)


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

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)


223
224
225
226
227
228
229
# File 'lib/active_fedora/relationships_helper.rb', line 223

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)


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

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.



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

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.



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

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.



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

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.



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

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.


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

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.



549
550
551
552
# File 'lib/active_fedora/relationships_helper.rb', line 549

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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



205
206
207
# File 'lib/active_fedora/relationships_helper.rb', line 205

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



143
144
145
# File 'lib/active_fedora/relationships_helper.rb', line 143

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



214
215
216
# File 'lib/active_fedora/relationships_helper.rb', line 214

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.



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

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.


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

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.



74
75
76
# File 'lib/active_fedora/relationships_helper.rb', line 74

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)



61
62
63
# File 'lib/active_fedora/relationships_helper.rb', line 61

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



258
259
260
261
262
263
264
265
266
# File 'lib/active_fedora/relationships_helper.rb', line 258

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



185
186
187
188
189
190
191
# File 'lib/active_fedora/relationships_helper.rb', line 185

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



161
162
163
# File 'lib/active_fedora/relationships_helper.rb', line 161

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



170
171
172
173
174
175
176
177
178
179
# File 'lib/active_fedora/relationships_helper.rb', line 170

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



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/active_fedora/relationships_helper.rb', line 374

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



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/active_fedora/relationships_helper.rb', line 88

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



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/active_fedora/relationships_helper.rb', line 105

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



241
242
243
# File 'lib/active_fedora/relationships_helper.rb', line 241

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



249
250
251
# File 'lib/active_fedora/relationships_helper.rb', line 249

def relationships_desc_from_class
  self.class.relationships_desc
end

#remove_named_relationship(name, object) ⇒ Object

Deprecated.

Please use #remove_relationship_by_name instead.



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

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



297
298
299
300
301
302
303
# File 'lib/active_fedora/relationships_helper.rb', line 297

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