Class: Effective::Classified
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::Classified
- Defined in:
- app/models/effective/classified.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#importing ⇒ Object
Returns the value of attribute importing.
Instance Method Summary collapse
- #approve! ⇒ Object
- #end_on_distance ⇒ Object
- #for_json ⇒ Object
- #published? ⇒ Boolean
- #purchasable_name ⇒ Object
- #submit! ⇒ Object
- #to_s ⇒ Object
- #unapprove! ⇒ Object
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
7 8 9 |
# File 'app/models/effective/classified.rb', line 7 def current_user @current_user end |
#importing ⇒ Object
Returns the value of attribute importing.
8 9 10 |
# File 'app/models/effective/classified.rb', line 8 def importing @importing end |
Instance Method Details
#approve! ⇒ Object
189 190 191 |
# File 'app/models/effective/classified.rb', line 189 def approve! approved! end |
#end_on_distance ⇒ Object
139 140 141 142 |
# File 'app/models/effective/classified.rb', line 139 def end_on_distance date = Time.zone.now ApplicationController.helpers.distance_of_time_in_words(date + EffectiveClassifieds.max_duration, date).gsub('about', '').strip end |
#for_json ⇒ Object
162 163 164 |
# File 'app/models/effective/classified.rb', line 162 def for_json { id: id, title: title, body: body.to_s, created_at: created_at, updated_at: updated_at } end |
#published? ⇒ Boolean
170 171 172 173 174 175 176 |
# File 'app/models/effective/classified.rb', line 170 def published? return false unless approved? return false if archived? return false if start_on.blank? || (Time.zone.now < start_on) return false if end_on.present? && (Time.zone.now >= end_on) true end |
#purchasable_name ⇒ Object
166 167 168 |
# File 'app/models/effective/classified.rb', line 166 def purchasable_name "#{category} - #{title}" end |
#submit! ⇒ Object
178 179 180 181 182 183 184 185 186 187 |
# File 'app/models/effective/classified.rb', line 178 def submit! submitted! approve! if EffectiveClassifieds.auto_approve after_commit do EffectiveClassifieds.send_email(:classified_submitted, self) end true end |
#to_s ⇒ Object
158 159 160 |
# File 'app/models/effective/classified.rb', line 158 def to_s title.presence || model_name.human end |
#unapprove! ⇒ Object
193 194 195 |
# File 'app/models/effective/classified.rb', line 193 def unapprove! unapproved! end |