Class: Calagator::Event::Saver

Inherits:
Struct
  • Object
show all
Defined in:
app/models/calagator/event/saver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



3
4
5
# File 'app/models/calagator/event/saver.rb', line 3

def event
  @event
end

#failureObject

Returns the value of attribute failure

Returns:

  • (Object)

    the current value of failure



3
4
5
# File 'app/models/calagator/event/saver.rb', line 3

def failure
  @failure
end

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



3
4
5
# File 'app/models/calagator/event/saver.rb', line 3

def params
  @params
end

Instance Method Details

#has_new_venue?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'app/models/calagator/event/saver.rb', line 14

def has_new_venue?
  return unless event.venue

  event.venue.previous_changes['id'] == [nil, event.venue.id] && params[:venue_name].present?
end

#saveObject



4
5
6
7
8
9
10
11
12
# File 'app/models/calagator/event/saver.rb', line 4

def save
  event.attributes = params[:event] || {}
  event.venue      = find_or_initialize_venue
  event.start_time = [params[:start_date], params[:start_time]].join(' ')
  event.end_time   = [params[:end_date], params[:end_time]].join(' ')
  event.tags.reload # Reload the #tags association because its members may have been modified when #tag_list was set above.

  attempt_save?
end