Module: Api::V1::ModelHash

Included in:
BaseController
Defined in:
lib/generators/happy_seed/api/templates/app/controllers/api/v1/model_hash.rb

Instance Method Summary collapse

Instance Method Details

#configuration_hashObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/generators/happy_seed/api/templates/app/controllers/api/v1/model_hash.rb', line 2

def configuration_hash
  {
      pusher: {
          url: Rails.application.secrets.pusher_url
      },
      aws: {
          access_key_id: Rails.application.secrets.aws_access_key_id,
          secret_access_key: Rails.application.secrets.aws_secret_access_key,
          s3_bucket: Rails.application.secrets.s3_bucket
      }
  }
end

#user_hash(user) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/generators/happy_seed/api/templates/app/controllers/api/v1/model_hash.rb', line 15

def user_hash(user)
  {
      id: user.id,
      login: user.,
      email: user.email,
      first_name: user.first_name,
      last_name: user.last_name
  }
end

#user_token_hash(user_token, *args) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/generators/happy_seed/api/templates/app/controllers/api/v1/model_hash.rb', line 25

def user_token_hash(user_token, *args)
  options = args.extract_options!
  output = {
      token: user_token.token,
      push_token: user_token.push_token
  }
  output.update(user: user_hash(user_token.user)) if true == options[:user]
  output
end