Skip to content

Commit 0dfe7ac

Browse files
committed
Merge pull request #162 from marshall-lee/master
Rewrite array methods delegation to @exposures.
2 parents b8cf779 + ed27575 commit 0dfe7ac

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,25 @@ def clear
2828
@exposures.clear
2929
end
3030

31-
delegate :each,
32-
:to_ary, :to_a,
33-
:[],
34-
:==,
35-
:size,
36-
:count,
37-
:length,
38-
:empty?,
39-
to: :@exposures
31+
[
32+
:each,
33+
:to_ary, :to_a,
34+
:all?,
35+
:select,
36+
:each_with_object,
37+
:[],
38+
:==,
39+
:size,
40+
:count,
41+
:length,
42+
:empty?
43+
].each do |name|
44+
class_eval <<-RUBY, __FILE__, __LINE__
45+
def #{name}(*args, &block)
46+
@exposures.#{name}(*args, &block)
47+
end
48+
RUBY
49+
end
4050

4151
# Determine if we have any nesting exposures with the same name.
4252
def deep_complex_nesting?

0 commit comments

Comments
 (0)