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 10 def initialize(exposures) @exposures = exposures @deep_complex_nesting = nil end
Public Instance Methods
<<(exposure)
click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 23 def <<(exposure) reset_memoization! @exposures << exposure end
clear()
click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 34 def clear reset_memoization! @exposures.clear end
deep_complex_nesting?(entity)
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 62 def deep_complex_nesting?(entity) if @deep_complex_nesting.nil? all_nesting = select(&:nesting?) @deep_complex_nesting = all_nesting .group_by { |exposure| exposure.key(entity) } .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 28 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 15 def find_by(attribute) @exposures.find { |e| e.attribute == attribute } end
select_by(attribute)
click to toggle source
# File lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb, line 19 def select_by(attribute) @exposures.select { |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 76 def reset_memoization! @deep_complex_nesting = nil end