Class: PhotoPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/photo_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_user

Instance Method Summary collapse

Methods inherited from BasePresenter

as_collection, #initialize, #method_missing, new

Constructor Details

This class inherits a constructor from BasePresenter

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BasePresenter

Instance Method Details

#as_api_json(full = false) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/presenters/photo_presenter.rb', line 21

def as_api_json(full=false)
  api_json = {
    dimensions: {
      height: height,
      width:  width
    },
    sizes:      {
      small:  url(:thumb_small),
      medium: url(:thumb_medium),
      large:  url(:scaled_full),
      raw:    url
    }
  }

  api_json[:guid] = guid if full
  api_json[:created_at] = created_at if full
  api_json[:post] = status_message_guid if full && status_message_guid
  api_json
end

#base_hashObject


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/presenters/photo_presenter.rb', line 4

def base_hash
  {
    id:         id,
    guid:       guid,
    dimensions: {
      height: height,
      width:  width
    },
    sizes:      {
      small:  url(:thumb_small),
      medium: url(:thumb_medium),
      large:  url(:scaled_full),
      raw:    url
    }
  }
end