Module: Marley::Plugins::MessageThreading::ClassMethods

Defined in:
lib/marley/joints/forum.rb

Instance Method Summary collapse

Instance Method Details

#list(params = {}) ⇒ Object



18
19
20
# File 'lib/marley/joints/forum.rb', line 18

def list(params={})
  reggae_instance_list(params)
end

#reggae_instance_list(params = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/marley/joints/forum.rb', line 21

def reggae_instance_list(params={})
  t=topics(params).all
  if t.length==0
    Marley::ReggaeMsg.new(:title => 'Nothing Found')
  else
    Marley::ReggaeInstanceList.new(
      :name => resource_name,
      :actions => {:get => :reply},
      :schema => t[0].reggae_schema(true),
      :items => t.map{|t| t.thread_vals},
      :recursive => true
    )
  end
end

#topics(params = nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/marley/joints/forum.rb', line 11

def topics(params=nil)
  filters=[]
  if params && params[:tags]
    filters << {:id => MR::Tag.join(:messages_tags, :tag_id => :id).select(:message_id).filter(:tag => params[:tags])}
  end
  filters.inject(self.roots) {|ds,f| ds.filter(f)}
end