Class: GoAction

Inherits:
Action
  • Object
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?

Methods included from OhNoes::Destroy

#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

.subtypesObject



39
40
41
# File 'app/models/actions/go_action.rb', line 39

def self.subtypes
  []
end

Instance Method Details

#action_typeObject



9
10
11
# File 'app/models/actions/go_action.rb', line 9

def action_type
  "Go"
end

#sentenceObject



17
18
19
20
21
22
23
24
# File 'app/models/actions/go_action.rb', line 17

def sentence
  #TODO: YUK. Do we still have to do this to discriminate from manually logged actions?
  if subject.is_a? Show
    verb + " " + self.details
  else
    " to a show"
  end
end

#showObject



5
6
7
# File 'app/models/actions/go_action.rb', line 5

def show
  subject
end

#verbObject



13
14
15
# File 'app/models/actions/go_action.rb', line 13

def verb
  "went"
end