Initial commit
This commit is contained in:
19
app/models/concerns/syncable.rb
Normal file
19
app/models/concerns/syncable.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Syncable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def as_json(params = {})
|
||||
json = super(params)
|
||||
json.each do |key, value|
|
||||
if key == "id"
|
||||
json[key] = value.to_s
|
||||
end
|
||||
end
|
||||
{
|
||||
id: id.to_s,
|
||||
type: model_name.param_key,
|
||||
attributes: json
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user