Skip to content

Instantly share code, notes, and snippets.

@tyama
Created February 8, 2010 09:07
Show Gist options
  • Save tyama/298003 to your computer and use it in GitHub Desktop.
Save tyama/298003 to your computer and use it in GitHub Desktop.
class FilterCore {
private String pattern
private String map
private DocObj mydoc
boolean proc = false
def FilterCore(String pattern,DocObj mydoc){
this.pattern = pattern
this.mydoc=mydoc
}
def tag(map){
this.map = map
return this
}
def save(){
println pattern + ":"+map
}
def process(boolean autosave = false){
if(!this.proc){
println "実行"
this.proc=true
this.mydoc.proc(this)
if(autosave)this.save()
this.proc=false
}
}
}
interface DocObj {
def filter(pattern)
def proc(obj)
}
class Viewer implements DocObj {
def filter(pattern){
return new FilterCore(pattern,this)
}
def proc(obj){
println "proc called:"+obj
}
}
def view = new Viewer()
view.filter("/パターン/").tag("{'name':'tyama'}").process(true)
view.filter("/パターン2/")
.tag("{'name':'tyama2'}")
.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment