Class: S3Secure::Policy::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_secure/policy/checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket_policy) ⇒ Checker

Returns a new instance of Checker.



3
4
5
# File 'lib/s3_secure/policy/checker.rb', line 3

def initialize(bucket_policy)
  @bucket_policy = bucket_policy # existing document policy
end

Instance Method Details

#has?(sid) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
# File 'lib/s3_secure/policy/checker.rb', line 7

def has?(sid)
  return false if @bucket_policy.blank?

  policy_document = JSON.load(@bucket_policy)
  statements = policy_document["Statement"]
  !!statements.detect { |s| s["Sid"] == sid }
end