Module: RestPack::Serializer::Single::ClassMethods

Defined in:
lib/restpack_serializer/serializable/single.rb

Instance Method Summary collapse

Instance Method Details

#single(params = {}, scope = nil, context = {}) ⇒ Object



5
6
7
8
9
10
# File 'lib/restpack_serializer/serializable/single.rb', line 5

def single(params = {}, scope = nil, context = {})
  options = RestPack::Serializer::Options.new(self, params, scope, context)
  model = options.scope_with_filters.first

  return model ? self.as_json(model, context) : nil
end