Class: OSX::ACL::Entries

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/acl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(acl, entries) ⇒ Entries

Returns a new instance of Entries.



37
38
39
40
# File 'lib/acl.rb', line 37

def initialize(acl, entries)
  @acl = acl
  super(entries)
end

Instance Attribute Details

#aclObject (readonly)

Returns the value of attribute acl.



36
37
38
# File 'lib/acl.rb', line 36

def acl
  @acl
end

Instance Method Details

#as_inheritedObject



41
42
43
# File 'lib/acl.rb', line 41

def as_inherited
  map {|entry| entry.inherited = true }
end

#remove_ifObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/acl.rb', line 45

def remove_if
  removal_count = 0
  # we reverse the order of the entries so we can remove entries without affecting the index of other entries
  reverse.each_with_index do |entry,index|
    if yield(entry)
      # since entries are reversed, we calculate the actual index
      actual_index = (length - 1) - index
      if acl.remove_entry_at_index(actual_index)
        removal_count += 1
      else
        raise "Failed to remove #{entry} from #{acl.path}"
      end
    end
  end
  removal_count
end