Module: Grape::Entity::Preloader::Exposure::Value

Defined in:
lib/grape/entity/preloader/exposure.rb

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#valid?(entity) ⇒ Boolean

Always return true for preloaded exposures since they are always valid The actual validation happens in the #value method

Returns:

  • (Boolean)


92
93
94
# File 'lib/grape/entity/preloader/exposure.rb', line 92

def valid?(entity)
  preload_callback ? true : super
end

#value(entity, options) ⇒ Object



85
86
87
88
# File 'lib/grape/entity/preloader/exposure.rb', line 85

def value(entity, options)
  cache = options.dig(PRELOAD_CACHE_KEY, preload_callback)
  cache.is_a?(Hash) ? cache[entity.object] : super
end