Class: Writ

Inherits:
Scrivener
  • Object
show all
Defined in:
lib/writ.rb,
lib/writ/version.rb

Defined Under Namespace

Classes: Outcome

Constant Summary collapse

VERSION =
"1.0.0".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(*args, &block) ⇒ Object

Public: Run the command with the provided input. Any arguments will be forwarded to ‘Writ#new`.

Returns a Writ::Outcome.



8
9
10
# File 'lib/writ.rb', line 8

def self.run(*args, &block)
  new(*args, &block).run!
end

Instance Method Details

#runObject

Internal: Runs your business logic, and assigns the return value of this method as the Outcome’s ‘#value`.

Returns an Object.



16
17
18
# File 'lib/writ.rb', line 16

def run
  fail NotImplementedError
end

#run!Object

Internal: Perform validations, run the business logic, and generate the outcome to return.

Returns a Writ::Outcome.



24
25
26
27
# File 'lib/writ.rb', line 24

def run!
  result = run if valid?
  Outcome.new(result, self)
end