Sha256: 3011f399dc83cb770a603f0fbe19dfa6fd5ad667cdcaeea5d3739821182c5540
Contents?: true
Size: 847 Bytes
Versions: 18
Compression:
Stored size: 847 Bytes
Contents
module Graphiti class FilterOperators class Catchall attr_reader :procs def initialize(resource, type_name, opts) @procs = {} defaults = resource.adapter.default_operators[type_name] || [:eq] if opts[:only] defaults = defaults.select { |op| Array(opts[:only]).include?(op) } end if opts[:except] defaults = defaults.reject { |op| Array(opts[:except]).include?(op) } end defaults.each do |op| @procs[op] = nil end end def method_missing(name, *args, &blk) @procs[name] = blk end def to_hash @procs end end def self.build(resource, type_name, opts = {}, &blk) c = Catchall.new(resource, type_name, opts) c.instance_eval(&blk) if blk c.to_hash end end end
Version data entries
18 entries across 18 versions & 1 rubygems