Module: Influxer::Scoping::Named::ClassMethods

Defined in:
lib/influxer/metrics/scoping/named.rb

Instance Method Summary collapse

Instance Method Details

#scope(name, scope) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/influxer/metrics/scoping/named.rb', line 11

def scope(name, scope)
  raise "Scope not defined: #{name}" if scope.nil? || !scope.respond_to?(:call)

  singleton_class.send(:define_method, name) do |*args|
    rel = all
    rel.merge!(rel.scoping { scope.call(*args) })
    rel
  end
end