Skip to content

Instantly share code, notes, and snippets.

@ryanguill
Created November 13, 2013 19:54
Show Gist options
  • Save ryanguill/7455295 to your computer and use it in GitHub Desktop.
Save ryanguill/7455295 to your computer and use it in GitHub Desktop.
<cfset t = new Test("bar") />
<cfdump var="#t#"/>
<cfset t.setFoo("public setter") />
<cfdump var="#t#" />
<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>
@ryanguill
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment