Class: Cure::Configuration::FileContentsHandler

Inherits:
DefaultFileHandler show all
Defined in:
lib/cure/config.rb

Instance Attribute Summary collapse

Attributes inherited from DefaultFileHandler

#ref_name, #type

Instance Method Summary collapse

Constructor Details

#initialize(file_contents, ref_name) ⇒ FileContentsHandler

Returns a new instance of FileContentsHandler.

Parameters:



173
174
175
176
# File 'lib/cure/config.rb', line 173

def initialize(file_contents, ref_name)
  super(:file_contents, ref_name)
  @file_contents = file_contents
end

Instance Attribute Details

#file_contentsString

Returns:



170
171
172
# File 'lib/cure/config.rb', line 170

def file_contents
  @file_contents
end

Instance Method Details

#descriptionObject



189
190
191
# File 'lib/cure/config.rb', line 189

def description
  "<content provided>"
end

#with_file(&_block) ⇒ Object



178
179
180
181
182
183
184
185
186
187
# File 'lib/cure/config.rb', line 178

def with_file(&_block)
  tmp_file = Tempfile.new('cure-temp')
  tmp_file.write(@file_contents)
  tmp_file.open

  yield tmp_file, @ref_name

ensure
  tmp_file.unlink
end