Module: RRRSpec::Server::JSONConstructor::TaskJSONConstructor

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Serializers::JSON
Included in:
Persistence::Task
Defined in:
lib/rrrspec/server/json_constructor.rb

Instance Method Summary collapse

Instance Method Details

#as_full_jsonObject



81
82
83
84
85
86
# File 'lib/rrrspec/server/json_constructor.rb', line 81

def as_full_json
  h = as_json(except: [:id, :taskset_id, :trials],
              include: { 'taskset' => { only: :key } })
  h['trials'] = trials.map(&:as_full_json)
  h
end

#as_json_for_result_pageObject



88
89
90
91
92
93
94
95
96
97
# File 'lib/rrrspec/server/json_constructor.rb', line 88

def as_json_for_result_page
  {
    'id' => id,
    'key' => key,
    'status' => status,
    'spec_path' => spec_file,
    'estimate_sec' => estimate_sec,
    'trials' => trials.map(&:as_json_for_result_page),
  }
end

#as_short_jsonObject



74
75
76
77
78
79
# File 'lib/rrrspec/server/json_constructor.rb', line 74

def as_short_json
  h = as_json(except: [:id, :taskset_id, :trials],
              include: { 'taskset' => { only: :key } })
  h['trials'] = trials.map { |trial| trial.as_json(only: :key) }
  h
end