Class: Grape::DryTypes::ParamsCache

Inherits:
Util::Cache show all
Defined in:
lib/grape/dry_types.rb

Constant Summary collapse

MAPPING =
{
  Grape::API::Boolean => DryTypes::Params::Bool,
  BigDecimal => DryTypes::Params::Decimal,
  Numeric => DryTypes::Params::Integer | DryTypes::Params::Float | DryTypes::Params::Decimal,
  TrueClass => DryTypes::Params::Bool.constrained(eql: true),
  FalseClass => DryTypes::Params::Bool.constrained(eql: false),
  String => DryTypes::Coercible::String
}.freeze

Instance Attribute Summary

Attributes inherited from Util::Cache

#cache

Instance Method Summary collapse

Constructor Details

#initializeParamsCache

Returns a new instance of ParamsCache.



38
39
40
41
42
43
44
45
# File 'lib/grape/dry_types.rb', line 38

def initialize
  super
  @cache = Hash.new do |h, params_type|
    h[params_type] = MAPPING.fetch(params_type) do
      DryTypes.wrapped_dry_types_const_get(DryTypes::Params, params_type)
    end
  end
end