Class: StatModule::JSONable
- Inherits:
-
Object
- Object
- StatModule::JSONable
show all
- Defined in:
- lib/JSONable.rb
Instance Method Summary
collapse
Instance Method Details
#to_json(excluded_fields = []) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/JSONable.rb', line 5
def to_json(excluded_fields = [])
hash = {}
self.instance_variables.each do |var|
hash[var.to_s.delete "@"] = self.instance_variable_get var unless excluded_fields.is_a?(Array) && excluded_fields.include?(var.to_s.delete "@")
end
hash.to_json
end
|