Merge pull request #4334 from eatkins/state-ops

Add an implicit class for StateOps
This commit is contained in:
eugene yokota 2018-09-16 02:40:12 -04:00 committed by GitHub
commit a943543291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -61,7 +61,7 @@ trait Identity {
}
/** Convenience methods for State transformations and operations. */
trait StateOps {
trait StateOps extends Any {
def process(f: (Exec, State) => State): State
/** Schedules `commands` to be run before any remaining commands.*/
@ -233,8 +233,11 @@ object State {
)
}
@deprecated("Import State._ or State.StateOpsImpl to access state extension methods", "1.3.0")
def stateOps(s: State): StateOps = new StateOpsImpl(s)
/** Provides operations and transformations on State. */
implicit def stateOps(s: State): StateOps = new StateOps {
implicit class StateOpsImpl(val s: State) extends AnyVal with StateOps {
def process(f: (Exec, State) => State): State = {
def runCmd(cmd: Exec, remainingCommands: List[Exec]) = {
log.debug(s"> $cmd")