Skip to content

Instantly share code, notes, and snippets.

@smoak
Forked from simensen/gist:1509272
Created December 22, 2011 06:51
Show Gist options
  • Save smoak/1509289 to your computer and use it in GitHub Desktop.
Save smoak/1509289 to your computer and use it in GitHub Desktop.
class Entity:
def __init__(self, jsonData)
self.jsonData = jsonData
@classmethod
def register_fields(cls, *fields):
for name in fields:
setattr(cls, name, property(lambda cls: cls.jsonData[name]))
class Org(Entity):
pass
Org.register_fields("avatar_url", "billing_email")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment