Sha256: 7da21c2211480d6b9023c914529d30d7f65d6dcfccdcb586ae516b72cb09ba90

Contents?: true

Size: 443 Bytes

Versions: 76

Compression:

Stored size: 443 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

class LHS::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

76 entries across 76 versions & 1 rubygems

Version Path
lhs-26.2.0 lib/lhs/concerns/record/scope.rb
lhs-26.1.0 lib/lhs/concerns/record/scope.rb
lhs-26.0.1 lib/lhs/concerns/record/scope.rb
lhs-26.0.0 lib/lhs/concerns/record/scope.rb
lhs-25.2.0 lib/lhs/concerns/record/scope.rb
lhs-25.1.0 lib/lhs/concerns/record/scope.rb
lhs-25.0.4 lib/lhs/concerns/record/scope.rb
lhs-25.0.3 lib/lhs/concerns/record/scope.rb
lhs-25.0.2 lib/lhs/concerns/record/scope.rb
lhs-25.0.1 lib/lhs/concerns/record/scope.rb
lhs-25.0.0 lib/lhs/concerns/record/scope.rb
lhs-24.1.2 lib/lhs/concerns/record/scope.rb
lhs-24.1.1 lib/lhs/concerns/record/scope.rb
lhs-24.1.0 lib/lhs/concerns/record/scope.rb
lhs-24.1.0.pre.2 lib/lhs/concerns/record/scope.rb
lhs-24.1.0.pre.1 lib/lhs/concerns/record/scope.rb
lhs-24.0.0 lib/lhs/concerns/record/scope.rb
lhs-23.0.2 lib/lhs/concerns/record/scope.rb
lhs-23.0.1 lib/lhs/concerns/record/scope.rb
lhs-23.0.0 lib/lhs/concerns/record/scope.rb