Sha256: da4bb49335cd3ecd08c19024948c2459efcc71ba917820e64495c05aeb49e3c8

Contents?: true

Size: 506 Bytes

Versions: 5

Compression:

Stored size: 506 Bytes

Contents

require 'active_support'
require_relative 'builder'

module ActiveRecordNestedScope
  module Extension
    extend ActiveSupport::Concern

    included do
      class_attribute :_nested_scope_options
    end

    class_methods do
      def nested_scope(name, options = {})
        self._nested_scope_options ||= {}
        self._nested_scope_options[name] = options

        scope name, ->(args) {
          ActiveRecordNestedScope::Builder.new(self, name, args).build
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activerecord_nested_scope-1.0.4 lib/activerecord_nested_scope/extension.rb
activerecord_nested_scope-1.0.3 lib/activerecord_nested_scope/extension.rb
activerecord_nested_scope-1.0.2 lib/activerecord_nested_scope/extension.rb
activerecord_nested_scope-1.0.1 lib/activerecord_nested_scope/extension.rb
activerecord_nested_scope-1.0.0 lib/activerecord_nested_scope/extension.rb