def to_params(self): """ Generates a Hash of property values for the current object. This helper handles all necessary type coercions as it generates its output. """ params = {} for name in self.PROPERTIES: attr = '_{0}'.format(name) value = getattr(self, attr, None) or getattr(self, name, None) # skip attribute if value is None: continue if isinstance(value, datetime): params[name] = format_time(value) elif isinstance(value, list): if not value: continue params[name] = ','.join(map(str, value)) elif isinstance(value, bool): params[name] = str(value).lower() else: params[name] = value return params
def to_params(self): """ Generates a Hash of property values for the current object. This helper handles all necessary type coercions as it generates its output. """ params = {} for name in self.PROPERTIES: attr = '_{0}'.format(name) value = getattr(self, attr, None) or getattr(self, name, None) # skip attribute if value is None: continue if isinstance(value, datetime): params[name] = format_time(value) elif isinstance(value, list): params[name] = ','.join(map(str, value)) elif isinstance(value, bool): params[name] = str(value).lower() else: params[name] = value return params