Class: Hydra::AccessControl

Inherits:
ActiveFedora::Base
  • Object
show all
Defined in:
app/models/hydra/access_control.rb

Defined Under Namespace

Classes: CollectionRelationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ownerObject

Returns the value of attribute owner.



11
12
13
# File 'app/models/hydra/access_control.rb', line 11

def owner
  @owner
end

Instance Method Details

#permissionsObject



13
14
15
# File 'app/models/hydra/access_control.rb', line 13

def permissions
  relationship
end

#permissions=(records) ⇒ Object



17
18
19
# File 'app/models/hydra/access_control.rb', line 17

def permissions=(records)
  relationship.replace(records)
end

#permissions_attributes=(attribute_list) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/hydra/access_control.rb', line 21

def permissions_attributes=(attribute_list)
  raise ArgumentError unless attribute_list.is_a? Array
  any_destroyed = false
  attribute_list.each do |attributes|
    if attributes.key?(:id)
      obj = relationship.find(attributes[:id])
      if has_destroy_flag?(attributes)
        obj.destroy
        any_destroyed = true
      else
        obj.update(attributes.except(:id, '_destroy'))
      end
    else
      relationship.create(attributes)
    end
  end
  # Poison the cache
  relationship.reset if any_destroyed
end

#relationshipObject



41
42
43
# File 'app/models/hydra/access_control.rb', line 41

def relationship
  @relationship ||= CollectionRelationship.new(self, :contains)
end