<cfcomponent
output="false"
hint="I provide base functionality for all primary model objects.">
<cfset VARIABLES.Instance = {} />
<cffunction
name="Get"
access="public"
returntype="any"
output="false"
hint="I return data from the instance properties.">
<cfargument
name="Property"
type="string"
required="true"
hint="I am the property that is being returned."
/>
<cfset var LOCAL = {} />
<cfif StructKeyExists( VARIABLES, "Get#ARGUMENTS.Property#" )>
<cfinvoke
method="Get#ARGUMENTS.Property#"
argumentcollection="#ARGUMENTS#"
returnvariable="LOCAL.Return"
/>
<cfreturn LOCAL.Return />
<cfelseif StructKeyExists( VARIABLES.Instance, ARGUMENTS.Property )>
<cfreturn VARIABLES.Instance[ ARGUMENTS.Property ] />
<cfelse>
<cfthrow
type="OOPhoto.BaseService.InvalidProperty"
message="The property you requested could not be found."
detail="The property you requested, #UCase( ARGUMENTS.Property )#, could not be accessed."
/>
</cfif>
</cffunction>
<cffunction
name="InjectDependency"
access="package"
returntype="any"
output="false"
hint="I inject dependency objecst into the VARIABLES scope of the extending Model object.">
<cfargument
name="Property"
type="string"
required="true"
hint="The key at which the dependency will be stored."
/>
<cfargument
name="Dependency"
type="any"
required="true"
hint="The dependency object that is being injected into the extending service object."
/>
<cfset VARIABLES[ ARGUMENTS.Property ] = ARGUMENTS.Dependency />
<cfreturn THIS />
</cffunction>
<cffunction
name="OnMissingMethod"
access="public"
returntype="any"
output="false"
hint="I handle calls to methods that do not exist.">
<cfargument
name="MissingMethodName"
type="string"
required="true"
hint="I am the name of the method that was called."
/>
<cfargument
name="MissingMethodArguments"
type="struct"
required="true"
hint="I am the arguments that were passed to the missing method."
/>
<cfset var LOCAL = {} />
<cfif REFindNoCase( "^Get.+", ARGUMENTS.MissingMethodName )>
<cfset LOCAL.Property = REReplace(
ARGUMENTS.MissingMethodName,
"^.{3}",
"",
"one"
) />
<cfreturn THIS.Get( LOCAL.Property ) />
<cfelseif REFindNoCase( "^Set.+", ARGUMENTS.MissingMethodName )>
<cfset LOCAL.Property = REReplace(
ARGUMENTS.MissingMethodName,
"^.{3}",
"",
"one"
) />
<cfreturn THIS.Set(
LOCAL.Property,
ARGUMENTS.MissingMethodArguments[ 1 ]
) />
<cfelse>
<cfthrow
type="OOPhoto.BaseService.InvalidMethod"
message="The method you requested could not be found."
detail="The method you requested, #UCase( ARGUMENTS.MissingMethodName )#, could not be accessed."
/>
</cfif>
</cffunction>
<cffunction
name="Set"
access="public"
returntype="any"
output="false"
hint="I store data to the instance properties.">
<cfargument
name="Property"
type="string"
required="true"
hint="I am the property that is being set."
/>
<cfargument
name="Value"
type="any"
required="true"
hint="I am the value being stored." />
<cfset var LOCAL = {} />
<cfif StructKeyExists( VARIABLES, "Set#ARGUMENTS.Property#" )>
<cfinvoke
method="Set#ARGUMENTS.Property#"
value="#ARGUMENTS.Value#"
/>
<cfelseif StructKeyExists( VARIABLES.Instance, ARGUMENTS.Property )>
<cfset VARIABLES.Instance[ ARGUMENTS.Property ] = ARGUMENTS.Value />
<cfelse>
<cfthrow
type="OOPhoto.BaseService.InvalidProperty"
message="The property you requested could not be found."
detail="The property you requested, #UCase( ARGUMENTS.Property )#, could not be accessed."
/>
</cfif>
<cfreturn THIS />
</cffunction>
</cfcomponent>