Class: Calagator::Event::Search
- Inherits:
-
Struct
- Object
- Struct
- Calagator::Event::Search
- Defined in:
- app/models/calagator/event/search.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#order ⇒ Object
Returns the value of attribute order.
-
#query ⇒ Object
Returns the value of attribute query.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #events ⇒ Object
- #failure_message ⇒ Object
-
#grouped_events ⇒ Object
Return
events
grouped by currentness using a data structure like:. - #hard_failure? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Search
constructor
A new instance of Search.
Constructor Details
#initialize(attributes = {}) ⇒ Search
Returns a new instance of Search.
5 6 7 8 9 10 11 |
# File 'app/models/calagator/event/search.rb', line 5 def initialize attributes = {} members.each do |key| send "#{key}=", attributes[key] end self.order ||= "date" validate! end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current
4 5 6 |
# File 'app/models/calagator/event/search.rb', line 4 def current @current end |
#order ⇒ Object
Returns the value of attribute order
4 5 6 |
# File 'app/models/calagator/event/search.rb', line 4 def order @order end |
#query ⇒ Object
Returns the value of attribute query
4 5 6 |
# File 'app/models/calagator/event/search.rb', line 4 def query @query end |
#tag ⇒ Object
Returns the value of attribute tag
4 5 6 |
# File 'app/models/calagator/event/search.rb', line 4 def tag @tag end |
Instance Method Details
#events ⇒ Object
13 14 15 |
# File 'app/models/calagator/event/search.rb', line 13 def events @events ||= perform_search end |
#failure_message ⇒ Object
35 36 37 |
# File 'app/models/calagator/event/search.rb', line 35 def @failure_message end |
#grouped_events ⇒ Object
Return events
grouped by currentness using a data structure like:
{
:current => [ my_current_event, my_other_current_event ],
:past => [ my_past_event ],
}
23 24 25 26 27 28 29 |
# File 'app/models/calagator/event/search.rb', line 23 def grouped_events grouped = events.group_by(&:current?) grouped = { current: grouped[true] || [], past: grouped[false] || [] } grouped[:current].reverse! if order.to_s == "date" grouped[:past] = [] if current grouped end |
#hard_failure? ⇒ Boolean
39 40 41 |
# File 'app/models/calagator/event/search.rb', line 39 def hard_failure? @hard_failure end |