Module: GCPT::JSONable
- Included in:
- BuildReport::BaseInfo, BuildReport::BuildMatric, BuildReport::ENVInfo, BuildReport::ExtraInfo, BuildReport::GsdkInfo, BuildReport::ProjectInfo, BuildReport::ReportInfo
- Defined in:
- lib/gcpt/utils/json_model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
12 13 14 |
# File 'lib/gcpt/utils/json_model.rb', line 12 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#as_json(options = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/gcpt/utils/json_model.rb', line 16 def as_json = {} serialized = Hash.new self.class.attributes.each do |attribute| value = self.public_send(attribute) serialized[attribute] = value if !value.nil? end serialized end |
#to_json(*a) ⇒ Object
25 26 27 |
# File 'lib/gcpt/utils/json_model.rb', line 25 def to_json *a as_json.to_json *a end |