Module: Respo::Serializers::Blueprinter
- Defined in:
- lib/respo/serializers/blueprinter.rb
Class Method Summary collapse
Class Method Details
.model_name(record) ⇒ Object
14 15 16 17 18 |
# File 'lib/respo/serializers/blueprinter.rb', line 14 def self.model_name(record) model_name = record&.class&.name wrapped = record.is_a?(Array) || model_name == 'ActiveRecord::Relation' wrapped ? record[0].class.name : model_name end |
.render(record, **args) ⇒ Object
6 7 8 |
# File 'lib/respo/serializers/blueprinter.rb', line 6 def self.render(record, **args) serializer_constant(record).render(record, **args) end |
.serializer_constant(record) ⇒ Object
10 11 12 |
# File 'lib/respo/serializers/blueprinter.rb', line 10 def self.serializer_constant(record) Object.const_get("#{model_name(record)}Blueprint") end |