Module: EnjuQuestion::QuestionManifestation::InstanceMethods

Defined in:
lib/enju_question/manifestation.rb

Instance Method Summary collapse

Instance Method Details

#questions(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/enju_question/manifestation.rb', line 14

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