as_jsonable
as_jsonable provides a tiny DSL to override as_json
.
Usage
class Employee < ActiveRecord::Base
as_json only: [:fisrt_name, :last_name]
end
This code equivalent to:
class Employee < ActiveRecord::Base
def as_json()
super({ only: [:fisrt_name, :last_name] }.merge())
end
end