Writing dynamic exposures by overriding initialize
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start in entity.rb at line 175 and inspect how exposures are appended to root_exposures. Reproduce the duplicate-exposure behavior described in the issue and review the reported test coverage. Done means repeated dynamic exposure initialization no longer degrades performance and regression coverage passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I've got a project that was still running 0.4.8 where, for example, we have Arrival and Departure types of Flight records, and the consumer wanted fields labelled as such. Rather than writing a bunch of boilerplate like:
expose :blah, as: :departure_blah, if: if: lambda {|o,_p| o.type == "Departure" }
I overrode the entity child class's initialize method:
def initialize(object, options = {})
if object
self.class.expose :blah, as: "#{type}_blah"
end
super(object, options)
end
This worked fine but after (finally) upgrading to 0.6.0 this started causing duplicate exposures to be added the root_exposures class variable, steadily degrading performance over time. Changing line 175 of entity.rb to root_exposures << exposure unless root_exposures.include?(exposure) fixes the issue, I've got test coverage written for that but following along the instructions for contributing I just get permission denied errors when attempting to push my branch.
Looking at that old code I realize that was an awful kludgey way of going about it.
- Ngôn ngữ chính
- Ruby
- Star
- 729
- Fork
- 154
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ruby-grape/grape-entity
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
ruby-grape/grape-entity#386 · 7 bình luận · 1 reaction ·
-
Custom Entity options support Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ruby-grape/grape-entity#382 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ruby-grape/grape-entity#380 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ruby-grape/grape-entity#373 · 2 bình luận ·
-
Truncate Formatter Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 45/100
ruby-grape/grape-entity#372 ·
Tất cả issue của ruby-grape/grape-entity
Issue tương tự
-
バグ
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Version bump for OpenVox 9 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
voxpupuli/puppet-epel#186 · 1 bình luận ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) Đang mởBug Frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
TheOdinProject/curriculum#31402 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100