Skip to content

Instantly share code, notes, and snippets.

@barelyknown
Created September 6, 2012 01:50
Show Gist options
  • Save barelyknown/3649793 to your computer and use it in GitHub Desktop.
Save barelyknown/3649793 to your computer and use it in GitHub Desktop.
Approach to Getter/Setter for Hash Access
def earliest_window_end
@earliest_window_end ||= {}
end
def method_missing(method, *args, &block)
if method =~ /^(.+?)_earliest_window_end(\=*)$/
!$2.blank? ? earliest_window_end[$1] = args[0] : earliest_window_end[$1]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment