Class: Grape::DryTypes::StrictCache

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

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Util::Cache

#cache

Instance Method Summary collapse

Constructor Details

#initializeStrictCache



18
19
20
21
22
23
24
25
# File 'lib/grape/dry_types.rb', line 18

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