class ParamsReady::Query::PredicateOperator
Public Class Methods
define_operator(name, altn, arel: nil, test: nil, inverse_of: nil)
click to toggle source
# File lib/params_ready/query/predicate_operator.rb, line 10 def self.define_operator(name, altn, arel: nil, test: nil, inverse_of: nil) define_singleton_method :name do name end define_singleton_method :altn do altn end if arel define_singleton_method :to_query do |attribute, value| attribute.send(arel, value) end end if test define_singleton_method :test do |record, attribute_name, value| attribute = record.send attribute_name attribute.send test, value end end define_singleton_method :inverse_of do inverse_of end unless PredicateRegistry.operator(self.name, Format.instance(:backend), true).nil? raise ParamsReadyError, "Operator name taken #{self.name}" end unless PredicateRegistry.operator(self.altn, Format.instance(:frontend), true).nil? raise ParamsReadyError, "Operator altn taken #{self.name}" end PredicateRegistry.register_operator_by_name self PredicateRegistry.register_operator_by_alt_name self end
dup()
click to toggle source
# File lib/params_ready/query/predicate_operator.rb, line 6 def self.dup self end
Public Instance Methods
altn()
click to toggle source
# File lib/params_ready/query/predicate_operator.rb, line 48 def altn self.class.altn end