Class: Easyhooks::Store

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/easyhooks/store.rb

Instance Method Summary collapse

Instance Method Details

#add_auth(type, auth) ⇒ Object



19
20
21
# File 'lib/easyhooks/store.rb', line 19

def add_auth(type, auth)
  values.create(context: 'auth', key: type, value: auth)
end

#add_headers(headers) ⇒ Object



13
14
15
16
17
# File 'lib/easyhooks/store.rb', line 13

def add_headers(headers)
  headers.each do |key, value|
    values.create(context: 'headers', key: key, value: value)
  end
end

#authObject



27
28
29
30
31
32
# File 'lib/easyhooks/store.rb', line 27

def auth
  auth = values.where(context: 'auth').first
  return nil unless auth.present?

  "#{auth.key} #{auth.value}"
end

#headersObject



23
24
25
# File 'lib/easyhooks/store.rb', line 23

def headers
  values.where(context: 'headers').map { |v| [v.key, v.value] }.to_h
end