Module: Grape::Entity::Exposure

Defined in:
lib/grape_entity/exposure.rb,
lib/grape_entity/exposure/base.rb,
lib/grape_entity/exposure/block_exposure.rb,
lib/grape_entity/exposure/nesting_exposure.rb,
lib/grape_entity/exposure/delegator_exposure.rb,
lib/grape_entity/exposure/formatter_exposure.rb,
lib/grape_entity/exposure/represent_exposure.rb,
lib/grape_entity/exposure/formatter_block_exposure.rb,
lib/grape_entity/exposure/nesting_exposure/output_builder.rb,
lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb

Defined Under Namespace

Classes: Base, BlockExposure, DelegatorExposure, FormatterBlockExposure, FormatterExposure, NestingExposure, RepresentExposure

Class Method Summary collapse

Class Method Details

.new(attribute, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/grape_entity/exposure.rb', line 16

def new(attribute, options)
  conditions = compile_conditions(attribute, options)
  base_args = [attribute, options, conditions]

  passed_proc = options[:proc]
  using_class = options[:using]
  format_with = options[:format_with]

  if using_class
    build_class_exposure(base_args, using_class, passed_proc)
  elsif passed_proc
    build_block_exposure(base_args, passed_proc)
  elsif format_with
    build_formatter_exposure(base_args, format_with)
  elsif options[:nesting]
    build_nesting_exposure(base_args)
  else
    build_delegator_exposure(base_args)
  end
end