Module: TaggedEventsController

Defined in:
lib/tagged_events_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/tagged_events_controller.rb', line 3

def self.included(base)
  base.class_eval {
    helper_method :tags, :url_with_tag, :url_without_tag
    alias_method_chain :event_finder, :tags
    alias_method_chain :continuing_events, :tags
    alias_method_chain :calendar_parameter_names, :tags
  }
end

Instance Method Details

#calendar_parameter_names_with_tagsObject



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

def calendar_parameter_names_with_tags
  calendar_parameter_names_without_tags + [:tags]
end

#continuing_events_with_tagsObject



22
23
24
25
26
# File 'lib/tagged_events_controller.rb', line 22

def continuing_events_with_tags
  continuing_events_without_tags
  @continuing_events = @continuing_events.from_all_tags(tags) if tags.any?
  @continuing_events
end

#event_finder_with_tagsObject



16
17
18
19
20
# File 'lib/tagged_events_controller.rb', line 16

def event_finder_with_tags
  ef = event_finder_without_tags
  ef = ef.from_all_tags(tags) if tags.any?
  ef
end

#tagsObject



12
13
14
# File 'lib/tagged_events_controller.rb', line 12

def tags
  @tags ||= Tag.from_list(params[:tags], false) || []
end

#url_with_tag(tag) ⇒ Object



38
39
40
41
42
# File 'lib/tagged_events_controller.rb', line 38

def url_with_tag(tag)
  url_for(url_parts({
    :tags => Tag.to_list(tags + [tag])
  }))
end

#url_without_tag(tag) ⇒ Object



32
33
34
35
36
# File 'lib/tagged_events_controller.rb', line 32

def url_without_tag(tag)
  url_for(url_parts({
    :tags => Tag.to_list(tags - [tag])
  }))
end