Class: Flipper::Generators::SetupGenerator::InjectIntoEncryptedFile
- Inherits:
-
Thor::Actions::InjectIntoFile
- Object
- Thor::Actions::InjectIntoFile
- Flipper::Generators::SetupGenerator::InjectIntoEncryptedFile
- Defined in:
- lib/generators/flipper/setup_generator.rb
Overview
Action to inject content into ActiveSupport::EncryptedFile
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(base, encrypted_file, data, config) ⇒ InjectIntoEncryptedFile
constructor
A new instance of InjectIntoEncryptedFile.
- #replace!(regexp, string, force) ⇒ Object
Constructor Details
#initialize(base, encrypted_file, data, config) ⇒ InjectIntoEncryptedFile
Returns a new instance of InjectIntoEncryptedFile.
44 45 46 47 |
# File 'lib/generators/flipper/setup_generator.rb', line 44 def initialize(base, encrypted_file, data, config) @encrypted_file = encrypted_file super(base, encrypted_file.content_path, data, config) end |
Instance Method Details
#content ⇒ Object
49 50 51 |
# File 'lib/generators/flipper/setup_generator.rb', line 49 def content @content ||= @encrypted_file.read end |
#replace!(regexp, string, force) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/generators/flipper/setup_generator.rb', line 53 def replace!(regexp, string, force) if force || !replacement_present? success = content.gsub!(regexp, string) @encrypted_file.write content unless pretend? success end end |