Class: Admin::Animals::ShowPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/admin/animals/show_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, animal) ⇒ ShowPresenter

Returns a new instance of ShowPresenter.


2
3
4
5
# File 'app/presenters/admin/animals/show_presenter.rb', line 2

def initialize(user, animal)
  @user = user
  @animal = animal
end

Instance Method Details

#animal_weightsObject


23
24
25
26
27
28
29
# File 'app/presenters/admin/animals/show_presenter.rb', line 23

def animal_weights
  weight_hash = {}
  @weights = AnimalWeight.where(animal_id: @animal.id).order(date_of_weight: :asc)
  weight_hash[:values] = @weights.map {|record| record.weight }
  weight_hash[:times] = @weights.map {|record| record.date_of_weight.strftime("%m/%d/%Y") }
  weight_hash
end

#colorsObject


15
16
17
# File 'app/presenters/admin/animals/show_presenter.rb', line 15

def colors
  AnimalColor.organization(@user).collect{|x| [x.id.to_s,x.color.to_s]}
end

#documentsObject


35
36
37
# File 'app/presenters/admin/animals/show_presenter.rb', line 35

def documents
  Document.where(documentable_id: @animal.id, documentable_type: 'Animal')
end

#notesObject


31
32
33
# File 'app/presenters/admin/animals/show_presenter.rb', line 31

def notes
  Note.includes(:user).where(animal_id: @animal.id).order(created_at: :asc)
end

#sheltersObject


19
20
21
# File 'app/presenters/admin/animals/show_presenter.rb', line 19

def shelters
  Shelter.organization(@user).collect{|x| [x.id.to_s,x.name.to_s]}
end

#shotsObject


39
40
41
# File 'app/presenters/admin/animals/show_presenter.rb', line 39

def shots
  @animal.shots
end

#speciesObject


11
12
13
# File 'app/presenters/admin/animals/show_presenter.rb', line 11

def species
  Species.organization(@user).collect{|x| [x.id.to_s,x.name.to_s]}
end

#statusesObject


7
8
9
# File 'app/presenters/admin/animals/show_presenter.rb', line 7

def statuses
  Status.organization(@user).collect{|x| [x.id.to_s,x.status.to_s]}
end