Sha256: 8568561ee55c8773b8eaf7e215b40ab888a5e7b60b51d255286ff8d57e651b2e

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

# frozen_string_literal: true

module ScopeHound
  # Helps to generate filter concerns
  module FilterScopable
    extend ActiveSupport::Concern

    def filter_scope(name, block)
      define_method(name) do |filter_value|
        return self if filter_value.blank?

        instance_exec(filter_value, &block)
      end
    end

    def filter_scope_path_for(scope, path = nil)
      path = scope.to_s if path.nil?
      filter_scopes_paths[scope] = path
    end

    def filter_scopes_paths
      @filter_scopes_paths ||= {}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scope_hound-0.1.0 app/models/concerns/scope_hound/filter_scopable.rb