Class: Calagator::Event
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Calagator::Event
- Includes:
- DecodeHtmlEntitiesHack, DuplicateChecking
- Defined in:
- app/models/calagator/event.rb,
app/models/calagator/event/saver.rb,
app/models/calagator/event/browse.rb,
app/models/calagator/event/cloner.rb,
app/models/calagator/event/search.rb,
app/models/calagator/event/overview.rb,
app/models/calagator/event/ical_renderer.rb,
app/models/calagator/event/search_engine.rb,
app/models/calagator/event/search_engine/sql.rb,
app/models/calagator/event/search_engine/apache_sunspot.rb
Defined Under Namespace
Classes: Browse, Cloner, IcalRenderer, Overview, Saver, Search, SearchEngine
Constant Summary
Constants included from DuplicateChecking
DuplicateChecking::DEFAULT_SQUASH_METHOD, DuplicateChecking::DUPLICATE_CHECKING_IGNORES_ATTRIBUTES, DuplicateChecking::DUPLICATE_MARK_COLUMN
Class Method Summary collapse
- .search(query, opts = {}) ⇒ Object
-
.search_tag(tag, opts = {}) ⇒ Object
—[ Searching ]——————————————————-.
Instance Method Summary collapse
-
#current? ⇒ Boolean
—[ Date related ]—————————————————-.
- #duration ⇒ Object
-
#end_time=(value) ⇒ Object
Set the end_time to the given
value
, which could be a Time, Date, DateTime, String, Array of Strings, or nil. -
#lock_editing! ⇒ Object
—[ Lock toggling ]—————————————————.
- #old? ⇒ Boolean
- #ongoing? ⇒ Boolean
-
#start_time=(value) ⇒ Object
Set the start_time to the given
value
, which could be a Time, Date, DateTime, String, Array of Strings, or nil. - #unlock_editing! ⇒ Object
-
#url=(value) ⇒ Object
—[ Overrides ]——————————————————-.
Methods included from DuplicateChecking
#duplicate?, #find_exact_duplicates, included, #master?, #progenitor
Methods included from DecodeHtmlEntitiesHack
#decode_html_entities, included
Class Method Details
.search(query, opts = {}) ⇒ Object
151 152 153 |
# File 'app/models/calagator/event.rb', line 151 def self.search(query, opts={}) SearchEngine.search(query, opts) end |
.search_tag(tag, opts = {}) ⇒ Object
—[ Searching ]——————————————————-
147 148 149 |
# File 'app/models/calagator/event.rb', line 147 def self.search_tag(tag, opts={}) includes(:venue).tagged_with(tag).ordered_by_ui_field(opts[:order]) end |
Instance Method Details
#current? ⇒ Boolean
—[ Date related ]—————————————————-
157 158 159 |
# File 'app/models/calagator/event.rb', line 157 def current? (end_time || start_time) >= Date.today.to_time end |
#duration ⇒ Object
170 171 172 173 |
# File 'app/models/calagator/event.rb', line 170 def duration return 0 unless end_time && start_time (end_time - start_time) end |
#end_time=(value) ⇒ Object
Set the end_time to the given value
, which could be a Time, Date, DateTime, String, Array of Strings, or nil.
121 122 123 124 125 126 |
# File 'app/models/calagator/event.rb', line 121 def end_time=(value) super time_for(value) rescue ArgumentError errors.add :end_time, "is invalid" super nil end |
#lock_editing! ⇒ Object
—[ Lock toggling ]—————————————————
137 138 139 |
# File 'app/models/calagator/event.rb', line 137 def lock_editing! update_attribute(:locked, true) end |
#old? ⇒ Boolean
161 162 163 |
# File 'app/models/calagator/event.rb', line 161 def old? (end_time || start_time + 1.hour) <= Time.zone.now.beginning_of_day end |
#ongoing? ⇒ Boolean
165 166 167 168 |
# File 'app/models/calagator/event.rb', line 165 def ongoing? return unless end_time && start_time (start_time..end_time).cover?(Date.today.to_time) end |
#start_time=(value) ⇒ Object
Set the start_time to the given value
, which could be a Time, Date, DateTime, String, Array of Strings, or nil.
112 113 114 115 116 117 |
# File 'app/models/calagator/event.rb', line 112 def start_time=(value) super time_for(value) rescue ArgumentError errors.add :start_time, "is invalid" super nil end |
#unlock_editing! ⇒ Object
141 142 143 |
# File 'app/models/calagator/event.rb', line 141 def unlock_editing! update_attribute(:locked, false) end |
#url=(value) ⇒ Object
—[ Overrides ]——————————————————-
106 107 108 |
# File 'app/models/calagator/event.rb', line 106 def url=(value) super UrlPrefixer.prefix(value) end |