Class: Cuprum::Rails::Serializers::Json::ActiveRecordSerializer
- Inherits:
-
BaseSerializer
- Object
- BaseSerializer
- Cuprum::Rails::Serializers::Json::ActiveRecordSerializer
- Defined in:
- lib/cuprum/rails/serializers/json/active_record_serializer.rb
Overview
Converts ActiveRecord record to JSON using the #as_json method.
Instance Method Summary collapse
-
#call(record, **_) ⇒ Hash
Converts the ActiveRecord record to JSON.
Methods inherited from BaseSerializer
Instance Method Details
#call(record, **_) ⇒ Hash
Converts the ActiveRecord record to JSON.
Calls and returns the #as_json method of the record.
16 17 18 19 20 21 22 |
# File 'lib/cuprum/rails/serializers/json/active_record_serializer.rb', line 16 def call(record, **_) unless record.is_a?(ActiveRecord::Base) raise ArgumentError, 'object must be an ActiveRecord record' end record.as_json end |