Module: Evently

Defined in:
lib/evently.rb,
lib/evently/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.asc(desc_by) ⇒ Object



28
29
30
# File 'lib/evently.rb', line 28

def self.asc(desc_by)
  Event.all.asc(desc_by)
end

.desc(desc_by) ⇒ Object



24
25
26
# File 'lib/evently.rb', line 24

def self.desc(desc_by)
  Event.all.desc(desc_by)
end

.fetch(*parts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/evently.rb', line 10

def self.fetch(*parts)
  parts.inject(Event) do |criteria, part|
    if part.is_a?(Mongoid::Document)
      criteria.where('event_parts.content.class_name' => part.class.name, 'event_parts.content.id' => part.id.to_s)
    else
      if part.is_a?(Array)
        criteria.all_in('event_parts.content' => part)
      else
        criteria.where('event_parts.content' => part)
      end
    end
  end
end

.record(*parts) ⇒ Object



6
7
8
# File 'lib/evently.rb', line 6

def self.record(*parts)
  Event.create(event_parts: parts.map { |part| EventPart.serialize_and_initialize(part) })
end