Sha256: 7e3d7d6a2647ec9ee7c143b81e6cb9081e3b2886922adf33abf8e63c565e9209
Contents?: true
Size: 833 Bytes
Versions: 9
Compression:
Stored size: 833 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| opts[:only].include?(op) } end if opts[:except] defaults = defaults.reject { |op| 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
9 entries across 9 versions & 1 rubygems