Sha256: d67ce9146e88bce179c997964dd3709c2f3c7030160c9753b22b6f1ea020f587

Contents?: true

Size: 443 Bytes

Versions: 12

Compression:

Stored size: 443 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

class DHS::Record

  # Scopes allow you to reuse common where queries
  module Scope
    extend ActiveSupport::Concern

    module ClassMethods
      def scope(name, block)
        scopes[name] = block
        define_singleton_method(name) do |*args|
          block.call(*args)
        end
      end

      def scopes
        @scopes ||= {}
        @scopes
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 lib/dhs/concerns/record/scope.rb
dhs-1.5.0 lib/dhs/concerns/record/scope.rb
dhs-1.4.2 lib/dhs/concerns/record/scope.rb
dhs-1.4.1 lib/dhs/concerns/record/scope.rb
dhs-1.4.0 lib/dhs/concerns/record/scope.rb
dhs-1.3.0 lib/dhs/concerns/record/scope.rb
dhs-1.2.0 lib/dhs/concerns/record/scope.rb
dhs-1.1.0 lib/dhs/concerns/record/scope.rb
dhs-1.0.3 lib/dhs/concerns/record/scope.rb
dhs-1.0.2 lib/dhs/concerns/record/scope.rb
dhs-1.0.1 lib/dhs/concerns/record/scope.rb
dhs-1.0.0 lib/dhs/concerns/record/scope.rb