Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2012 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4382511 to your computer and use it in GitHub Desktop.
Save anonymous/4382511 to your computer and use it in GitHub Desktop.
`property` method
class athena.lib.Model
property: (property) =>
(value) =>
if value?
@model.set property, value
else
@model.get property
class YouTubeShell.Model extends VideoLinkShell.Model
# get/setter
startTime: => (@property 'startTime') ...arguments
# getter only
getYouTubeAPIData: => (@property 'ytData')()
# set value from youtube api before returning
getTotalTime: =>
if @YouTubeAPI.duration then (@property 'totalTime') @YouTubeAPI.duration
(@property 'totalTime')()
# setter only, in case you ever wanted one
setUngettableValue: =>
(@property 'ungettableValue') ...arguments
undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment