Class: Architecture::Prepend

Inherits:
Object
  • Object
show all
Includes:
Contentable, Entityable
Defined in:
lib/architecture/prepend.rb

Instance Method Summary collapse

Constructor Details

#initialize(source:, content: "", context: {}) ⇒ Prepend

Returns a new instance of Prepend.



6
7
8
9
10
# File 'lib/architecture/prepend.rb', line 6

def initialize(source:, content: "", context: {})
  @entity = Entity.new(path: source)
  @content = content
  @context = context
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
# File 'lib/architecture/prepend.rb', line 12

def call
  if entity.file?
    entity.write(text: data)
  else
    raise ArgumentError, "Source wasn't a file"
  end
end