module ActiveZuora::Scoping::ClassMethods
Public Instance Methods
exclude_from_queries(*field_names)
click to toggle source
# File lib/active_zuora/scoping.rb, line 30 def exclude_from_queries(*field_names) (@excluded_from_queries ||= []).concat field_names.map(&:to_sym) end
relation()
click to toggle source
# File lib/active_zuora/scoping.rb, line 34 def relation query_field_names = field_names - (@excluded_from_queries ||= []) Relation.new(self, query_field_names) end
scope(name, body)
click to toggle source
# File lib/active_zuora/scoping.rb, line 39 def scope(name, body) # Body can be a Relation or a lambda that returns a relation. define_singleton_method(name) do |*args| body.respond_to?(:call) ? body.call(*args) : scoped.merge(body) end end
scoped()
click to toggle source
# File lib/active_zuora/scoping.rb, line 22 def scoped current_scope || relation end
unscoped() { || ... }
click to toggle source
# File lib/active_zuora/scoping.rb, line 26 def unscoped block_given? ? relation.scoped { yield } : relation end