Sha256: 304625eb8b78eb6e73015dc252c3eacdae2f440c50e504f9eb96aefebf75af78

Contents?: true

Size: 547 Bytes

Versions: 3

Compression:

Stored size: 547 Bytes

Contents

module ActiveHashRelation::ScopeFilters
  def filter_scopes(resource, params, model = nil)
    unless model
      model = model_class_name(resource)
      if model.nil? || engine_name == model.to_s
        model = model_class_name(resource, true)
      end
    end

    model.scope_names.each do |scope|
      if params.include?(scope)
        if params[scope].is_a? Array
          resource = resource.send(scope, *params[scope])
        else
          resource = resource.send(scope)
        end
      end
    end

    return resource
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_hash_relation-1.4.1 lib/active_hash_relation/scope_filters.rb
active_hash_relation-1.4.0 lib/active_hash_relation/scope_filters.rb
active_hash_relation-1.2.0 lib/active_hash_relation/scope_filters.rb