Sha256: 860d12508bb4f2002c36b32def28b80a55e5ffb1ae9a324fd2ed6c7cccae6a0a

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

module Worthwhile
  class QuickClassificationQuery

    def self.each_for_context(*args, &block)
      new(*args).all.each(&block)
    end

    attr_reader :user

    def initialize(user, options = {})
      @user = user
      @concern_name_normalizer = options.fetch(:concern_name_normalizer, ClassifyConcern.method(:to_class))
      @registered_curation_concern_names = options.fetch(:registered_curation_concern_names, Worthwhile.configuration.registered_curation_concern_types)
    end

    def all
      ActiveFedora::Base.logger.debug "User is #{user}"
      ActiveFedora::Base.logger.debug "try is #{normalized_curation_concern_names.first}"
      ActiveFedora::Base.logger.debug "can is  #{user.can?(:create, normalized_curation_concern_names.first)}"
      normalized_curation_concern_names.select {|klass| user.can?(:create, klass)}
    end

    private

    attr_reader :concern_name_normalizer, :registered_curation_concern_names

    def normalized_curation_concern_names
      registered_curation_concern_names.collect{|name| concern_name_normalizer.call(name) }
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
worthwhile-0.1.2 worthwhile-models/app/models/worthwhile/quick_classification_query.rb
worthwhile-models-0.1.2 app/models/worthwhile/quick_classification_query.rb
worthwhile-0.1.1 worthwhile-models/app/models/worthwhile/quick_classification_query.rb
worthwhile-models-0.1.1 app/models/worthwhile/quick_classification_query.rb
worthwhile-0.1.0 worthwhile-models/app/models/worthwhile/quick_classification_query.rb
worthwhile-models-0.1.0 app/models/worthwhile/quick_classification_query.rb
worthwhile-0.0.3 app/models/worthwhile/quick_classification_query.rb
worthwhile-0.0.2 app/models/worthwhile/quick_classification_query.rb
worthwhile-0.0.1 app/models/worthwhile/quick_classification_query.rb