Created
November 13, 2013 19:54
-
-
Save ryanguill/7455295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset t = new Test("bar") /> | |
<cfdump var="#t#"/> | |
<cfset t.setFoo("public setter") /> | |
<cfdump var="#t#" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent name="test" accessors="true"> | |
<cfproperty name="foo" type="string" /> | |
<cffunction name="init" access="public" returntype="any" output="false"> | |
<cfargument name="foo" type="string" required="true" /> | |
<cfset setFoo(arguments.foo) /> | |
<cfreturn this /> | |
</cffunction> | |
<cffunction name="setFoo" access="private" returntype="void" output="false"> | |
<cfargument name="value" type="string" required="true" /> | |
<cfset variables.foo = "set by private setter" /> | |
</cffunction> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
setting accessors="true" in the component, but overriding the generated setter and making it private makes effectively two methods - a private one that is used internally and a public one that is called externally.