class Spree::Core::QueryFilters::Comparable
Attributes
attribute[R]
Public Class Methods
new(attribute:)
click to toggle source
# File lib/spree/core/query_filters/comparable.rb, line 5 def initialize(attribute:) @attribute = attribute end
Public Instance Methods
call(scope:, filter:)
click to toggle source
# File lib/spree/core/query_filters/comparable.rb, line 9 def call(scope:, filter:) scope = gt(scope, filter[:gt]) scope = gteq(scope, filter[:gteq]) scope = lt(scope, filter[:lt]) lteq(scope, filter[:lteq]) end
Private Instance Methods
gt(scope, value)
click to toggle source
# File lib/spree/core/query_filters/comparable.rb, line 20 def gt(scope, value) return scope unless value scope.where(attribute.gt(value)) end
gteq(scope, value)
click to toggle source
# File lib/spree/core/query_filters/comparable.rb, line 26 def gteq(scope, value) return scope unless value scope.where(attribute.gteq(value)) end
lt(scope, value)
click to toggle source
# File lib/spree/core/query_filters/comparable.rb, line 32 def lt(scope, value) return scope unless value scope.where(attribute.lt(value)) end
lteq(scope, value)
click to toggle source
# File lib/spree/core/query_filters/comparable.rb, line 38 def lteq(scope, value) return scope unless value scope.where(attribute.lteq(value)) end