Module: Borrower::DSL
- Defined in:
- lib/borrower.rb
Instance Method Summary collapse
-
#borrow(path, options = {}, &block) ⇒ Void
borrow a file and put it somewhere by adding a merge: argument of true borrower will parse the contents for additional borrow statements to merge.
Instance Method Details
#borrow(path, options = {}, &block) ⇒ Void
borrow a file and put it somewhere by adding a merge: argument of true borrower will parse the contents for additional borrow statements to merge
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/borrower.rb', line 37 def borrow path, ={}, &block destination = .delete(:to) { raise ArgumentError, "missing 'to:' argument" } on_conflict = .delete(:on_conflict) { nil } content = Borrower.take(path) if content.valid_encoding? content = Borrower.merge(content, ) if .fetch(:merge) { false } content = yield content if block_given? end Borrower.put *[content, destination, on_conflict].compact end |