Class: GoAction
- Inherits:
-
Action
- Object
- ActiveRecord::Base
- Action
- GoAction
show all
- Defined in:
- app/models/actions/go_action.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Action
create_of_type, #default_starred_to_false, #editable?, for_organization, from_open_struct, #full_details, #quip, recent, #set_creator, #set_params, subtypes_by_type, #to_open_struct, #unstarred?
#destroy, #destroyable?
Class Method Details
.for(show, person, occurred_at = nil, &block) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/actions/go_action.rb', line 26
def self.for(show, person, occurred_at=nil, &block)
existing_action = GoAction.where({:subject_id => show.id, :person_id => person.id}).first
return existing_action || GoAction.new.tap do |go_action|
go_action.person = person
go_action.subject = show
go_action.details = "to #{show.event.name} on #{I18n.l show.parsed_local_datetime, :format => :short}"
go_action.organization = show.organization
time_zone = show.time_zone
go_action.occurred_at = ( occurred_at.nil? ? show.parsed_local_datetime.beginning_of_day : occurred_at )
block.call(go_action) if block.present?
end
end
|
.subtypes ⇒ Object
39
40
41
|
# File 'app/models/actions/go_action.rb', line 39
def self.subtypes
[]
end
|
Instance Method Details
#action_type ⇒ Object
9
10
11
|
# File 'app/models/actions/go_action.rb', line 9
def action_type
"Go"
end
|
#sentence ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'app/models/actions/go_action.rb', line 17
def sentence
if subject.is_a? Show
verb + " " + self.details
else
" to a show"
end
end
|
#show ⇒ Object
5
6
7
|
# File 'app/models/actions/go_action.rb', line 5
def show
subject
end
|
#verb ⇒ Object
13
14
15
|
# File 'app/models/actions/go_action.rb', line 13
def verb
"went"
end
|