Sha256: 86e4dffde644a43cf6c6717bfe8470a41b0713e1db4b4161b79b78366fceb83d

Contents?: true

Size: 515 Bytes

Versions: 3

Compression:

Stored size: 515 Bytes

Contents

module ActiveModel
  module Serializable
    def as_json(options={})
      if root = options.fetch(:root, json_key)
        hash = { root => serializable_object }
        hash.merge!(serializable_data)
        hash
      else
        serializable_object
      end
    end

    def serializable_data
      embedded_in_root_associations.tap do |hash|
        if respond_to?(:meta) && meta
          hash[meta_key] = meta
        end
      end
    end

    def embedded_in_root_associations
      {}
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
active_model_serializers_rails_2.3-0.9.0.alpha1 lib/active_model/serializable.rb
active_model_serializers-0.9.0.alpha1 lib/active_model/serializable.rb
active_model_serializers_rails_2.3-0.9.0.pre2 lib/active_model/serializable.rb