Module: EnjuQuestion::EnjuManifestation

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/enju_question/enju_manifestation.rb

Instance Method Summary collapse

Instance Method Details

#questions(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/concerns/enju_question/enju_manifestation.rb', line 5

def questions(options = {})
  id = self.id
  options = {page: 1, per_page: Question.default_per_page}.merge(options)
  page = options[:page]
  per_page = options[:per_page]
  user = options[:user]
  Question.search do
    with(:manifestation_id).equal_to id
    any_of do
      unless user.try(:has_role?, 'Librarian')
        with(:shared).equal_to true
      #  with(:username).equal_to user.try(:username)
      end
    end
    paginate page: page, per_page: per_page
  end.results
end