class CanCamel::Filters::Base
Public Class Methods
new(*)
click to toggle source
# File lib/can_camel/filters/base.rb, line 3 def initialize(*) end
Public Instance Methods
catch_args()
click to toggle source
# File lib/can_camel/filters/base.rb, line 10 def catch_args nil end
catch_result()
click to toggle source
# File lib/can_camel/filters/base.rb, line 14 def catch_result [] end
filter(**_)
click to toggle source
# File lib/can_camel/filters/base.rb, line 18 def filter(**_) {} end
invoke!(args: {}, result: {})
click to toggle source
# File lib/can_camel/filters/base.rb, line 26 def invoke!(args: {}, result: {}) args = my_slice(args, catch_args) if catch_args args.merge! my_slice(result, catch_result) { |l, r, _k| r || l } filter(**args) end
lint!()
click to toggle source
# File lib/can_camel/filters/base.rb, line 22 def lint! raise CanCamel::Linter::LintingError if (catch_args & catch_result).try(:any?) end
name()
click to toggle source
# File lib/can_camel/filters/base.rb, line 6 def name self.class.to_s.demodulize.underscore.to_sym end
validates(*args)
click to toggle source
# File lib/can_camel/filters/base.rb, line 32 def validates(*args) CanCamel::Validators.validates(name, *args) end
Private Instance Methods
my_slice(hash, args)
click to toggle source
# File lib/can_camel/filters/base.rb, line 38 def my_slice(hash, args) args.each_with_object({}) { |x, object| object[x] = hash[x] } end