Sha256: 54b05653f52761207916d160c5ee026c109184738f627d2fa80206c2d9056d95
Contents?: true
Size: 762 Bytes
Versions: 93
Compression:
Stored size: 762 Bytes
Contents
# frozen_string_literal: true module Motor module ApiQuery module ApplyScope module_function def call(rel, scope) return rel if scope.blank? scope_symbol = scope.to_sym if rel.klass.defined_scopes.include?(scope_symbol) rel.public_send(scope_symbol) else apply_filter_scope(rel, scope) end end def apply_filter_scope(rel, scope) configs = Motor::Resource.find_by(name: rel.klass.name.underscore) return rel unless configs scope_configs = configs.preferences[:scopes].find { |s| s[:name] == scope } return rel unless scope_configs ApiQuery::Filter.call(rel, scope_configs[:preferences][:filter]) end end end end
Version data entries
93 entries across 93 versions & 1 rubygems