Module: Serializable::ClassMethods

Defined in:
app/models/concerns/serializable.rb

Instance Method Summary collapse

Instance Method Details

#serialize_it(with: nil, options: {}) ⇒ Object


5
6
7
8
9
# File 'app/models/concerns/serializable.rb', line 5

def serialize_it(with: nil, options: {})
  scope = current_scope || default_scope {}
  serializer = with || scope.active_model_serializer
  serializer.new(scope, options)
end

#serialized_object(options: {}) ⇒ Object


11
12
13
# File 'app/models/concerns/serializable.rb', line 11

def serialized_object(options: {})
  serialize_it(options).as_json
end