module Archipel::Api::Internal::XmlMessages

Protected Instance Methods

generate_password(length) click to toggle source
# File lib/archipel/api/internal/xml_messages.rb, line 18
def generate_password length
  # http://stackoverflow.com/a/88341/504845
  chars = [('a'..'z'), ('A'..'Z'), ('0' .. '9')].map { |i| i.to_a }.flatten
  (0...length).map { chars[rand(chars.length)] }.join
end
render(template, **values) click to toggle source
# File lib/archipel/api/internal/xml_messages.rb, line 5
def render template, **values
  current_dir = File.dirname __FILE__
  templates_dir = "#{current_dir}/xml/#{subdir}"
  template_file = "#{template}.xml.erb"
  ActionView::Base.new(templates_dir).render \
      file: template_file,
      locals: values
end
subdir() click to toggle source
# File lib/archipel/api/internal/xml_messages.rb, line 14
def subdir
  self.class.name.match('Archipel::Api::Internal::(.*)XmlMessages')[1].downcase
end