Module: Grape::Entity::Preloader::Exposure::Base

Extended by:
ActiveSupport::Concern
Defined in:
lib/grape/entity/preloader/exposure.rb

Overview

rubocop:disable Style/Documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#preloadObject (readonly)

Returns the value of attribute preload.



10
11
12
# File 'lib/grape/entity/preloader/exposure.rb', line 10

def preload
  @preload
end

Instance Method Details

#initialize(_attribute, options, _conditions) ⇒ Object



12
13
14
15
16
17
# File 'lib/grape/entity/preloader/exposure.rb', line 12

def initialize(_attribute, options, _conditions)
  @preload = options[:preload]
  validate_preload_option!

  super
end

#preload_associationObject



19
20
21
22
23
24
25
26
27
# File 'lib/grape/entity/preloader/exposure.rb', line 19

def preload_association
  case preload
  when Symbol
    preload
  when Array
    value = preload[0]
    value.is_a?(Symbol) ? value : nil
  end
end

#preload_callbackObject



29
30
31
32
33
34
35
36
37
# File 'lib/grape/entity/preloader/exposure.rb', line 29

def preload_callback
  case preload
  when Proc
    preload
  when Array
    value = preload[0]
    value.is_a?(Proc) ? value : nil
  end
end

#preload_conditionObject



39
40
41
# File 'lib/grape/entity/preloader/exposure.rb', line 39

def preload_condition
  preload.last if preload.is_a?(Array)
end