Class: Cumulus::IAM::AssumeRoleUnifier
- Inherits:
-
Object
- Object
- Cumulus::IAM::AssumeRoleUnifier
- Defined in:
- lib/iam/migration/AssumeRoleUnifier.rb
Overview
Public: A class that keeps track of strings, writing them to file and unifying them if they are identical. Specifically, this is use for the assume role document on roles
Instance Method Summary collapse
-
#initialize(dir, &save) ⇒ AssumeRoleUnifier
constructor
Public: Constructor.
-
#unify(config, s, name) ⇒ Object
Public: Unify a string with any previous instances of the string.
Constructor Details
#initialize(dir, &save) ⇒ AssumeRoleUnifier
Public: Constructor.
dir - the directory to write assets to save - a function that will save a value to a config. Takes the value and
the config as paramters.
12 13 14 15 16 |
# File 'lib/iam/migration/AssumeRoleUnifier.rb', line 12 def initialize(dir, &save) @dir = dir @strings = {} @save = save end |
Instance Method Details
#unify(config, s, name) ⇒ Object
Public: Unify a string with any previous instances of the string
config - the config object that the string should belong to s - the string to unify name - the name of the file this string should be saved to if needed
23 24 25 26 27 28 29 30 31 |
# File 'lib/iam/migration/AssumeRoleUnifier.rb', line 23 def unify(config, s, name) if !@strings.has_key?(s) File.open("#{@dir}/#{name}", 'w') { |f| f.write(s) } @strings[s] = name @save.call(config, name) else @save.call(config, @strings[s]) end end |