ColdFusion でメソッドチェーン的なものが出来ると気づいたので。
サンプルは下記を参考に
http://qiita.com/t_ishida/items/bae7e62950d81f427f13
cfml形式で
Friends.cfc
<cfcomponent>
<cfset this.message = "" >
<!---
<cffunction name="init">
<cfset this.message = "">
<cfreturn this >
</cffunction>
--->
<cffunction name="wai" >
<cfset this.message &= "わーい" & chr(13) & chr(10) >
<cfreturn this >
</cffunction>
<cffunction name="sugoi">
<cfset this.message &= "すごーい" & chr(13) & chr(10) >
<cfreturn this>
</cffunction>
<cffunction name="tanoshii">
<cfset this.message &= "たのしー" & chr(13) & chr(10) >
<cfreturn this>
</cffunction>
<cffunction name="friends">
<cfargument name="skill" required="yes" type="string" >
<cfset this.message &= "君は#arguments.skill#がとくいな、フレンズなんだね!!" & chr(13) & chr(10) >
<cfreturn this>
</cffunction>
output.cfm
<cfset writeDump(new Friends().wai().sugoi().tanoshii().friends("●●").toString()) >
わーい すごーい たのしー 君は●●がとくいな、フレンズなんだね!!
もしくは cfscript形式で
Friends.cfc
<cfscript>
component{
this.message = "";
/*
public Friends function init(){
this.message = "";
return this;
}
*/
public Friends function wai(){
this.message &= "わーい" & chr(13) & chr(10);
return this;
}
public Friends function sugoi(){
this.message &= "すごーい" & chr(13) & chr(10);
return this;
}
public Friends function tanoshii(){
this.message &= "たのしー" & chr(13) & chr(10);
return this;
}
public Friends function friends(required string skill){
this.message &= "君は#arguments.skill#がとくいな、フレンズなんだね!!" & chr(13) & chr(10);
return this;
}
public string function toString(){
return this.message;
}
}
</cfscript>
output.cfm
<cfscript>
writeDump(new Friends().wai().sugoi().tanoshii().friends("●●").toString());
</cfscript>
わーい すごーい たのしー 君は●●がとくいな、フレンズなんだね!!