class AWS::S3::Policy::Statement

def resource_arn resource

def resource_arn resource
  prefix = 'arn:aws:s3:::'
  case resource
  when Bucket
    "#{prefix}#{resource.name}"
  when S3Object
    "#{prefix}#{resource.bucket.name}/#{resource.key}"
  when ObjectCollection
    "#{prefix}#{resource.bucket.name}/#{resource.prefix}*"
  when /^arn:/
    resource
  else
    "arn:aws:s3:::#{resource}"
  end
end