Class: Dato::Dump::Operation::CreateDataFile

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/dump/operation/create_data_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, path, format, value) ⇒ CreateDataFile

Returns a new instance of CreateDataFile.



12
13
14
15
16
17
# File 'lib/dato/dump/operation/create_data_file.rb', line 12

def initialize(context, path, format, value)
  @context = context
  @path = path
  @format = format
  @value = value
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



10
11
12
# File 'lib/dato/dump/operation/create_data_file.rb', line 10

def context
  @context
end

#formatObject (readonly)

Returns the value of attribute format.



10
11
12
# File 'lib/dato/dump/operation/create_data_file.rb', line 10

def format
  @format
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/dato/dump/operation/create_data_file.rb', line 10

def path
  @path
end

#valueObject (readonly)

Returns the value of attribute value.



10
11
12
# File 'lib/dato/dump/operation/create_data_file.rb', line 10

def value
  @value
end

Instance Method Details

#performObject



19
20
21
22
23
24
25
# File 'lib/dato/dump/operation/create_data_file.rb', line 19

def perform
  FileUtils.mkdir_p(File.dirname(path))

  File.open(File.join(context.path, path), "w") do |file|
    file.write Format.dump(format, value)
  end
end