Module: Komonjo::Extension::ToJson
- Included in:
- Model::Message, Model::Profile, Model::User
- Defined in:
- lib/komonjo/extensions/to_json.rb
Overview
generate to_json method
Instance Method Summary collapse
Instance Method Details
#to_json(*args) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/komonjo/extensions/to_json.rb', line 5 def to_json(*args) ret = instance_variables.each_with_object({}) do |attr, hash| # remove head @ key = attr.to_s key[0] = '' hash[key.to_sym] = instance_variable_get(attr) end ret.to_json(*args) end |