How to get the specified expose
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
The issue shows User's expose declarations and the Entity::User.represent_only call; start by checking how represent_only handles the listed symbols and options hash. Document the correct selection syntax and the expected JSON result, including conditional exposes.
Written by the indexing model from the issue text.
Description
User Entity
class User < EEntity
expose :id, :name, :pinyin, :account_id, :hidden, :dept_id, :actived
expose :initialism, as: :short_pinyin
expose :role_code
expose :login_name
expose(:email, if: lambda { |u, op| op[:included_user_email] == true }) do |u, options|
u.email
end
expose :cellvoice1, if: lambda { |u, op| !op[:no_privacy] } do |u, options|
if u.get_user_info
u.get_user_info.cellvoice1
else
nil
end
end
expose :nickname do |u, options|
if u.get_user_info
u.get_user_info.nickname
else
nil
end
end
expose :workvoice do |u, options|
if u.get_user_info
u.get_user_info.workvoice
else
nil
end
end
expose :dept_name do |u, options|
uinfo = u.get_user_info
if uinfo
uinfo.get_dept_display_name
else
nil
end
end
end
How to get some of these exposes?
example:
::Entity::User.represent_only([:name.:pinyin, :account_id, :hidden, :dept_id ],{}).as_json
Result:
{
name: 'xxx',
pinyin: 'xxx',
account_id: 1,
hidden: true,
dept_id: 2
}
- Dominant language
- Ruby
- Stars
- 729
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby-grape/grape-entity
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ruby-grape/grape-entity#386 · 7 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ruby-grape/grape-entity#382 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ruby-grape/grape-entity#380 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ruby-grape/grape-entity#373 · 2 comments ·
-
Truncate Formatter Open
Difficulty 1/5 1-3 hours Newbie friendliness 45/100
ruby-grape/grape-entity#372 ·
All issues in ruby-grape/grape-entity
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bensheldon/good_job#1816 · 5 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·