Sha256: 08fcfd40408806382eb51e3e1a6258a79ffccc1f3838e2c84a0ca7121219b93b

Contents?: true

Size: 456 Bytes

Versions: 5

Compression:

Stored size: 456 Bytes

Contents

module Influxer
  module Scoping
    module Named
      extend ActiveSupport::Concern

      module ClassMethods
        def scope(name, scope)
          raise Error.new("Scope not defined: #{name}") if scope.nil? or !scope.respond_to?(:call)
          singleton_class.send(:define_method, name) do |*args|
            rel = all
            rel.merge!(rel.scoping { scope.call(*args) })
            rel
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
influxer-0.2.2 lib/influxer/metrics/scoping/named.rb
influxer-0.2.0 lib/influxer/metrics/scoping/named.rb
influxer-0.1.2 lib/influxer/metrics/scoping/named.rb
influxer-0.1.1 lib/influxer/metrics/scoping/named.rb
influxer-0.1.0 lib/influxer/metrics/scoping/named.rb