class Grape::Entity::Exposure::NestingExposure::NestedExposures

Public Class Methods

new(exposures) click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 8
def initialize(exposures)
  @exposures = exposures
end

Public Instance Methods

<<(exposure) click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 16
def <<(exposure)
  reset_memoization!
  @exposures << exposure
end
clear() click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 27
def clear
  reset_memoization!
  @exposures.clear
end
deep_complex_nesting?() click to toggle source

Determine if we have any nesting exposures with the same name.

# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 53
def deep_complex_nesting?
  if @deep_complex_nesting.nil?
    all_nesting = select(&:nesting?)
    @deep_complex_nesting = all_nesting.group_by(&:key).any? { |_key, exposures| exposures.length > 1 }
  else
    @deep_complex_nesting
  end
end
delete_by(*attributes) click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 21
def delete_by(*attributes)
  reset_memoization!
  @exposures.reject! { |e| attributes.include? e.attribute }
  @exposures
end
find_by(attribute) click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 12
def find_by(attribute)
  @exposures.find { |e| e.attribute == attribute }
end

Private Instance Methods

reset_memoization!() click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 64
def reset_memoization!
  @deep_complex_nesting = nil
end