Last active
August 13, 2020 08:16
-
-
Save 3014zhangshuo/d8fd4689c4a078f493fa434d0bd44e02 to your computer and use it in GitHub Desktop.
没有使用到的代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def use_scope_info | |
| %i[klass content_key attributes_query current_usager_ids] | |
| .each_with_object(ActiveSupport::OrderedOptions.new) do |k, object| | |
| object[k] = USE_SCOPE_INFO.dig(k, usager_type.to_sym) | |
| end | |
| end | |
| USE_SCOPE_INFO = { | |
| klass: { | |
| agents: Agent, | |
| agent_groups: UserGroup | |
| }, | |
| content_key: { | |
| agents: :agent_ids, | |
| agent_groups: :agent_group_ids | |
| }, | |
| attributes_query: { | |
| agents: 'id, nick_name AS name', | |
| agent_groups: 'id, name' | |
| }, | |
| current_usager_ids: { | |
| agents: ->(agent) { [agent.id] }, | |
| agent_groups: ->(agent) { agent.user_groups.ids } | |
| } | |
| }.freeze |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment