-
Notifications
You must be signed in to change notification settings - Fork 1
Reko States
Thomas Starzynski edited this page May 28, 2019
·
3 revisions
- The model
Rekohas an integer field calledstate, which can have 3 different values:-
open(default) donerejected
-
- in the database,
stateis encoded as an integer mapped to the three values provided. The encoding is as follows (0: open,1: done,2: rejected) - the default value is 0 (= open)
- in the ruby world, Active Record provides us with methods that enhance readibility of the code. (see code snippet below)
- more info here
# CREATE NEW REKO
reko = Reko.new # status is "open"
# check status
reko.status # returns a strig "open"
# build in methods to check each status
reko.open? # => true
reko.done? # => false
reko.rejected? # => false
# build in methods to change the status
reko.open! # => sets status to 0 ("open")
reko.done! # => sets status to 1 ("done")
reko.rejected! # => sets status to 2 ("rejected")