Class: Cumulus::IAM::StatementConfig
- Inherits:
-
Object
- Object
- Cumulus::IAM::StatementConfig
- Defined in:
- lib/iam/models/StatementConfig.rb
Overview
Public: Represents a policy config file.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#effect ⇒ Object
readonly
Returns the value of attribute effect.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#as_hash ⇒ Object
Public: Create a Hash that contains the data in this StatementConfig which can be turned into JSON that matches the format for AWS IAMS.
-
#initialize(json) ⇒ StatementConfig
constructor
Public: Constructor.
Constructor Details
#initialize(json) ⇒ StatementConfig
Public: Constructor.
json - the Hash containing the JSON configuration for this StatementConfig
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/iam/models/StatementConfig.rb', line 13 def initialize(json) @effect = json["Effect"] # Action and Resource elements are sometimes strings instead of arrays of strings. @action = if json["Action"].is_a? Array json["Action"].sort elsif json["Action"].is_a? String # convert single element strings into arrays json["Action"] = [json["Action"]] else raise Exception.new("invalid policy statement resource") end @resource = if json["Resource"].is_a? Array json["Resource"].sort elsif json["Resource"].is_a? String # convert single element strings into arrays json["Resource"] = [json["Resource"]] else raise Exception.new("invalid policy statement resource") end @condition = json["Condition"] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/iam/models/StatementConfig.rb', line 7 def action @action end |
#effect ⇒ Object (readonly)
Returns the value of attribute effect.
6 7 8 |
# File 'lib/iam/models/StatementConfig.rb', line 6 def effect @effect end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
8 9 10 |
# File 'lib/iam/models/StatementConfig.rb', line 8 def resource @resource end |
Instance Method Details
#as_hash ⇒ Object
Public: Create a Hash that contains the data in this StatementConfig which can be turned into JSON that matches the format for AWS IAMS.
Returns the Hash representing this StatementConfig.
39 40 41 42 43 44 45 46 |
# File 'lib/iam/models/StatementConfig.rb', line 39 def as_hash Hash[{ "Effect" => @effect, "Action" => @action, "Resource" => @resource, "Condition" => @condition }.sort].reject { |k, v| v.nil? } end |