Class: Hyrax::QuickClassificationQuery
- Inherits:
-
Object
- Object
- Hyrax::QuickClassificationQuery
- Defined in:
- app/services/hyrax/quick_classification_query.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#all? ⇒ Boolean
True if the requested concerns is same as all avaliable concerns.
-
#authorized_models ⇒ Array
A list of all the requested concerns that the user can create.
- #each(&block) ⇒ Object
-
#initialize(user, options = {}) ⇒ QuickClassificationQuery
constructor
A new instance of QuickClassificationQuery.
Constructor Details
#initialize(user, options = {}) ⇒ QuickClassificationQuery
Returns a new instance of QuickClassificationQuery.
9 10 11 12 13 |
# File 'app/services/hyrax/quick_classification_query.rb', line 9 def initialize(user, = {}) @user = user @concern_name_normalizer = .fetch(:concern_name_normalizer, ->(str) { str.constantize }) @models = .fetch(:models, Hyrax.config.registered_curation_concern_types) end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/services/hyrax/quick_classification_query.rb', line 3 def user @user end |
Instance Method Details
#all? ⇒ Boolean
Returns true if the requested concerns is same as all avaliable concerns.
20 21 22 |
# File 'app/services/hyrax/quick_classification_query.rb', line 20 def all? models == Hyrax.config.registered_curation_concern_types end |
#authorized_models ⇒ Array
Returns a list of all the requested concerns that the user can create.
25 26 27 |
# File 'app/services/hyrax/quick_classification_query.rb', line 25 def normalized_model_names.select { |klass| user.can?(:create, klass) } end |
#each(&block) ⇒ Object
15 16 17 |
# File 'app/services/hyrax/quick_classification_query.rb', line 15 def each(&block) .each(&block) end |