Class: Effective::Event

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/event.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



127
128
129
# File 'app/models/effective/event.rb', line 127

def body
  rich_text_body
end

#closed?Boolean

Returns:

  • (Boolean)


144
145
146
147
# File 'app/models/effective/event.rb', line 144

def closed?
  return false if registration_end_at.blank?
  registration_end_at < Time.zone.now
end

#duplicateObject

Returns a duplicated event object, or throws an exception



174
175
176
177
178
179
180
181
182
183
# File 'app/models/effective/event.rb', line 174

def duplicate
  Event.new(attributes.except('id', 'updated_at', 'created_at')).tap do |event|
    event.title = event.title + ' (Copy)'
    event.slug = event.slug + '-copy'
    event.draft = true

    event.body = body
    event.excerpt = excerpt
  end
end

#duplicate!Object



185
186
187
# File 'app/models/effective/event.rb', line 185

def duplicate!
  duplicate.tap { |event| event.save! }
end

#early_bird?Boolean

Returns:

  • (Boolean)


153
154
155
156
# File 'app/models/effective/event.rb', line 153

def early_bird?
  return false if early_bird_end_at.blank?
  early_bird_end_at > Time.zone.now
end

#early_bird_past?Boolean

Returns:

  • (Boolean)


158
159
160
161
# File 'app/models/effective/event.rb', line 158

def early_bird_past?
  return false if early_bird_end_at.blank?
  early_bird_end_at <= Time.zone.now
end

#early_bird_statusObject



163
164
165
166
167
168
169
170
171
# File 'app/models/effective/event.rb', line 163

def early_bird_status
  if early_bird?
    'Early Bird Pricing'
  elsif early_bird_past?
    'Expired'
  else
    'None'
  end
end

#excerptObject



131
132
133
# File 'app/models/effective/event.rb', line 131

def excerpt
  rich_text_excerpt
end

#registerable?Boolean

Returns:

  • (Boolean)


135
136
137
138
139
140
141
142
# File 'app/models/effective/event.rb', line 135

def registerable?
  return false if draft?
  return false if closed?
  return false if sold_out?
  return false if event_tickets.blank?

  true
end

#sold_out?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'app/models/effective/event.rb', line 149

def sold_out?
  false
end

#to_sObject



123
124
125
# File 'app/models/effective/event.rb', line 123

def to_s
  title.presence || 'New Event'
end