Class: Hyrax::QuickClassificationQuery
- Inherits:
-
Object
- Object
- Hyrax::QuickClassificationQuery
- Defined in:
- app/services/hyrax/quick_classification_query.rb
Overview
Provides an enumerator of the Work classes the user is authorized to create.
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
(also: #to_a)
A list of all the requested concerns that the user can create.
- #each(&block) ⇒ Object
-
#initialize(user, models: Hyrax.config.registered_curation_concern_types, concern_name_normalizer: ->(str) { str.constantize }) ⇒ QuickClassificationQuery
constructor
A new instance of QuickClassificationQuery.
Constructor Details
#initialize(user, models: Hyrax.config.registered_curation_concern_types, concern_name_normalizer: ->(str) { str.constantize }) ⇒ QuickClassificationQuery
Returns a new instance of QuickClassificationQuery.
17 18 19 20 21 22 23 |
# File 'app/services/hyrax/quick_classification_query.rb', line 17 def initialize(user, models: Hyrax.config.registered_curation_concern_types, concern_name_normalizer: ->(str) { str.constantize }) @user = user @concern_name_normalizer = concern_name_normalizer @models = models end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
12 13 14 |
# File 'app/services/hyrax/quick_classification_query.rb', line 12 def user @user end |
Instance Method Details
#all? ⇒ Boolean
Returns true if the requested concerns is same as all avaliable concerns.
30 31 32 |
# File 'app/services/hyrax/quick_classification_query.rb', line 30 def all? models == Hyrax.config.registered_curation_concern_types end |
#authorized_models ⇒ Array Also known as: to_a
Returns a list of all the requested concerns that the user can create.
35 36 37 |
# File 'app/services/hyrax/quick_classification_query.rb', line 35 def normalized_model_names.select { |klass| user.can?(:create, klass) } end |
#each(&block) ⇒ Object
25 26 27 |
# File 'app/services/hyrax/quick_classification_query.rb', line 25 def each(&block) .each(&block) end |