Class: Imap::Backup::Serializer::PermissionChecker
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::PermissionChecker
- Defined in:
- lib/imap/backup/serializer/permission_checker.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
Instance Method Summary collapse
-
#initialize(filename:, limit:) ⇒ PermissionChecker
constructor
A new instance of PermissionChecker.
- #run ⇒ Object
Constructor Details
#initialize(filename:, limit:) ⇒ PermissionChecker
Returns a new instance of PermissionChecker.
8 9 10 11 |
# File 'lib/imap/backup/serializer/permission_checker.rb', line 8 def initialize(filename:, limit:) @filename = filename @limit = limit end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/imap/backup/serializer/permission_checker.rb', line 5 def filename @filename end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
6 7 8 |
# File 'lib/imap/backup/serializer/permission_checker.rb', line 6 def limit @limit end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/imap/backup/serializer/permission_checker.rb', line 13 def run actual = FileMode.new(filename: filename).mode return nil if actual.nil? mask = ~limit & 0o777 return if (actual & mask).zero? = format( "Permissions on '%<filename>s' " \ "should be 0%<limit>o, not 0%<actual>o", filename: filename, limit: limit, actual: actual ) raise end |