Class: Thor::Actions::CreateFile

Inherits:
Templater show all
Defined in:
lib/thor/actions/create_file.rb

Overview

AddFile is a subset of Template, which instead of rendering a file with ERB, it gets the content from the user.

Instance Attribute Summary collapse

Attributes inherited from Templater

#base, #destination, #given_destination, #relative_destination, #source

Instance Method Summary collapse

Methods inherited from Templater

#exists?, #identical?, #invoke!, #revoke!

Constructor Details

#initialize(base, destination, data, log_status) ⇒ CreateFile

Returns a new instance of CreateFile.



34
35
36
37
# File 'lib/thor/actions/create_file.rb', line 34

def initialize(base, destination, data, log_status)
  super(base, nil, destination, log_status)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

:nodoc:



32
33
34
# File 'lib/thor/actions/create_file.rb', line 32

def data
  @data
end

Instance Method Details

#renderObject



39
40
41
42
43
44
45
# File 'lib/thor/actions/create_file.rb', line 39

def render
  @render ||= if data.is_a?(Proc)
    data.call
  else
    data
  end
end