Skip to content

Instantly share code, notes, and snippets.

@mrico
Created December 27, 2010 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrico/756051 to your computer and use it in GitHub Desktop.
Save mrico/756051 to your computer and use it in GitHub Desktop.
Question about Record's EnumField and Enumeration types
import net.liftweb._
import record._
import record.field._
object State extends State
sealed abstract class State extends Enumeration("created", "destroyed") {
type State = Value
val Created, Destroyed = Value
}
class Thing extends Record[Thing] {
def meta = Thing
object state extends EnumField(this, State, State.Created)
}
object Thing extends Thing with MetaRecord[Thing]
object Test {
def switch(state: State#Value) =
if(state == State.Created) State.Destroyed else State.Created
val thing = Thing.createRecord
thing.state.set(State.Created)
switch(thing.state.is) == switch(State.Destroyed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment