@@ -349,31 +349,6 @@ def associations(include_directive = ActiveModelSerializers.default_include_dire
349349 # @return [Hash] containing the attributes and first level
350350 # associations, similar to how ActiveModel::Serializers::JSON is used
351351 # in ActiveRecord::Base.
352- #
353- # TODO: Include <tt>ActiveModel::Serializers::JSON</tt>.
354- # So that the below is true:
355- # @param options [nil, Hash] The same valid options passed to `serializable_hash`
356- # (:only, :except, :methods, and :include).
357- #
358- # See
359- # https://github.com/rails/rails/blob/v5.0.0.beta2/activemodel/lib/active_model/serializers/json.rb#L17-L101
360- # https://github.com/rails/rails/blob/v5.0.0.beta2/activemodel/lib/active_model/serialization.rb#L85-L123
361- # https://github.com/rails/rails/blob/v5.0.0.beta2/activerecord/lib/active_record/serialization.rb#L11-L17
362- # https://github.com/rails/rails/blob/v5.0.0.beta2/activesupport/lib/active_support/core_ext/object/json.rb#L147-L162
363- #
364- # @example
365- # # The :only and :except options can be used to limit the attributes included, and work
366- # # similar to the attributes method.
367- # serializer.as_json(only: [:id, :name])
368- # serializer.as_json(except: [:id, :created_at, :age])
369- #
370- # # To include the result of some method calls on the model use :methods:
371- # serializer.as_json(methods: :permalink)
372- #
373- # # To include associations use :include:
374- # serializer.as_json(include: :posts)
375- # # Second level and higher order associations work as well:
376- # serializer.as_json(include: { posts: { include: { comments: { only: :body } }, only: :title } })
377352 def serializable_hash ( adapter_options = nil , options = { } , adapter_instance = self . class . serialization_adapter_instance )
378353 adapter_options ||= { }
379354 options [ :include_directive ] ||= ActiveModel ::Serializer . include_directive_from_options ( adapter_options )
@@ -385,13 +360,6 @@ def serializable_hash(adapter_options = nil, options = {}, adapter_instance = se
385360 alias to_h serializable_hash
386361
387362 # @see #serializable_hash
388- # TODO: When moving attributes adapter logic here, @see #serializable_hash
389- # So that the below is true:
390- # @param options [nil, Hash] The same valid options passed to `as_json`
391- # (:root, :only, :except, :methods, and :include).
392- # The default for `root` is nil.
393- # The default value for include_root is false. You can change it to true if the given
394- # JSON string includes a single root node.
395363 def as_json ( adapter_opts = nil )
396364 serializable_hash ( adapter_opts )
397365 end
0 commit comments