Improvements from Rails plugin template

This commit is contained in:
Benjamin Fleischer
2016-04-01 04:12:30 -05:00
parent 96c5516d21
commit 21b2eff2ab
11 changed files with 61 additions and 19 deletions

View File

@@ -2,16 +2,15 @@ module ActiveModel
class Serializer
# This class hold all information about serializer's association.
#
# @param [Symbol] name
# @param [ActiveModel::Serializer] serializer
# @param [Hash{Symbol => Object}] options
# @attr [Symbol] name
# @attr [ActiveModel::Serializer] serializer
# @attr [Hash{Symbol => Object}] options
#
# @example
# Association.new(:comments, CommentSummarySerializer)
#
Association = Struct.new(:name, :serializer, :options, :links, :meta) do
# @return [Symbol]
#
def key
options.fetch(:key, name)
end

View File

@@ -74,7 +74,7 @@ module ActiveModel
# Sets +::_cache+ object to <tt>ActionController::Base.cache_store</tt>
# when Rails.configuration.action_controller.perform_caching
#
# @params options [Hash] with valid keys:
# @param options [Hash] with valid keys:
# cache_store : @see ::_cache
# key : @see ::_cache_key
# only : @see ::_cache_only

View File

@@ -26,7 +26,7 @@ module ActiveModelSerializers
ActiveModelSerializers::Adapter.lookup(adapter)
end
# @return Hash<adapter_name, adapter_class>
# @return [Hash<adapter_name, adapter_class>]
def adapter_map
ADAPTER_MAP
end

View File

@@ -8,8 +8,8 @@ module ActiveModelSerializers
# Builds a JSON API Errors Object
# {http://jsonapi.org/format/#errors JSON API Errors}
#
# @param [ActiveModel::Serializer::ErrorSerializer]
# @return [Array<Symbol, Array<String>] i.e. attribute_name, [attribute_errors]
# @param [ActiveModel::Serializer::ErrorSerializer] error_serializer
# @return [Array<Symbol, Array<String>>] i.e. attribute_name, [attribute_errors]
def self.resource_errors(error_serializer)
error_serializer.as_json.flat_map do |attribute_name, attribute_errors|
attribute_error_objects(attribute_name, attribute_errors)

View File

@@ -52,8 +52,9 @@ module ActiveModelSerializers
end
# find all cache_key for the collection_serializer
# @param collection_serializer
# @param include_tree
# @param serializers [ActiveModel::Serializer::CollectionSerializer]
# @param adapter_instance [ActiveModelSerializers::Adapter::Base]
# @param include_tree [ActiveModel::Serializer::IncludeTree]
# @return [Array] all cache_key of collection_serializer
def self.object_cache_keys(serializers, adapter_instance, include_tree)
cache_keys = []

View File

@@ -2,8 +2,8 @@ module ActiveModelSerializers
module Test
module Schema
# A Minitest Assertion that test the response is valid against a schema.
# @params schema_path [String] a custom schema path
# @params message [String] a custom error message
# @param schema_path [String] a custom schema path
# @param message [String] a custom error message
# @return [Boolean] true when the response is valid
# @return [Minitest::Assertion] when the response is invalid
# @example