Class: Calagator::Event::Cloner

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

Constant Summary collapse

ATTRIBUTES =
[:title, :description, :venue_id, :url, :tag_list, :venue_details]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



7
8
9
# File 'app/models/calagator/event/cloner.rb', line 7

def event
  @event
end

Class Method Details

.clone(event) ⇒ Object



8
9
10
# File 'app/models/calagator/event/cloner.rb', line 8

def self.clone(event)
  new(event).clone
end

Instance Method Details

#cloneObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/calagator/event/cloner.rb', line 14

def clone
  clone = Event.new
  ATTRIBUTES.each do |attribute|
    clone.send "#{attribute}=", event.send(attribute)
  end
  if event.start_time
    clone.start_time = clone_time_for_today(event.start_time)
  end
  if event.end_time
    clone.end_time = clone_time_for_today(event.end_time)
  end
  clone
end