Skip to content

Instantly share code, notes, and snippets.

@3014zhangshuo
Last active August 13, 2020 08:16
Show Gist options
  • Save 3014zhangshuo/d8fd4689c4a078f493fa434d0bd44e02 to your computer and use it in GitHub Desktop.
Save 3014zhangshuo/d8fd4689c4a078f493fa434d0bd44e02 to your computer and use it in GitHub Desktop.
没有使用到的代码
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