class Whiteprint::AttributeScope
Public Class Methods
new(scope, model: nil)
click to toggle source
# File lib/whiteprint/attributes.rb, line 76 def initialize(scope, model: nil) @scope = scope @model = model @selects = [] @rejects = [] end
Public Instance Methods
filter()
click to toggle source
# File lib/whiteprint/attributes.rb, line 97 def filter select = proc { |scope, condition| scope.select(&condition) } reject = proc { |scope, condition| scope.reject(&condition) } scope = @selects.inject(@scope, &select) @rejects.inject(scope, &reject) end
not(*keys, **conditions)
click to toggle source
# File lib/whiteprint/attributes.rb, line 90 def not(*keys, **conditions) @rejects << proc do |_, attribute| attribute.has?(*keys, **conditions) end Attributes.new(filter, model: @model) end
where(*keys, **conditions)
click to toggle source
# File lib/whiteprint/attributes.rb, line 83 def where(*keys, **conditions) @selects << proc do |_, attribute| attribute.has?(*keys, **conditions) end Attributes.new(filter, model: @model) end