class Gatleon::Rails::Authform::User

Constants

PERMITTED_CHARS

Public Class Methods

new(json:, _form_secret_key:, _authform_base_url:) click to toggle source
# File lib/gatleon/rails/authform/user.rb, line 7
def initialize(json:, _form_secret_key:, _authform_base_url:)
  @json = json

  @_form_secret_key = _form_secret_key
  @_authform_base_url = _authform_base_url
end

Public Instance Methods

[](key) click to toggle source

Getters

# File lib/gatleon/rails/authform/user.rb, line 26
def [](key)
  @json[key.to_s]
end
[]=(key, value) click to toggle source

Setters

# File lib/gatleon/rails/authform/user.rb, line 32
def []=(key, value)
  key = _clean_key(key)

  raise ArgumentError, "can't set reserved field name #{key}" if key[0] == "_" # anything starting with _

  raise ArgumentError, "can't set empty field name" if key == ""

  raise ArgumentError, "only characters a-z, A-Z, 0-9, and _ permitted in field name" unless key.match?(PERMITTED_CHARS)

  @json[key] = value.to_s
end
_email() click to toggle source
# File lib/gatleon/rails/authform/user.rb, line 20
def _email
  @json["_email"]
end
_id() click to toggle source

Getters

# File lib/gatleon/rails/authform/user.rb, line 16
def _id
  @json["_id"]
end

Private Instance Methods

_clean_key(k_or_v) click to toggle source
# File lib/gatleon/rails/authform/user.rb, line 56
def _clean_key(k_or_v)
  k_or_v.to_s.strip
end
_persist(key, value) click to toggle source
# File lib/gatleon/rails/authform/user.rb, line 46
def _persist(key, value)
  uri = _persist_url(key, vlue)
  
  Net::HTTP.get_response(uri) # TODO: move to post request
end
_persist_url(key, value) click to toggle source
# File lib/gatleon/rails/authform/user.rb, line 52
def _persist_url(key, value)
  URI("#{@_authform_base_url}/v1/setUser?_id=#{_id}&_secretKey=#{@_form_secret_key}&#{key}=#{value}")
end