<commit_before>require "erb"

module AdaptivePay
  class Interface

    attr_accessor :base_url, :environment, :username, :password, :signature

    def initialize(rails_env=nil)
      load(rails_env||Rails.env) unless rails_env == false
    end

    def load(rails_env)
      config = YAML.load(ERB.new(File.read(File.join(Rails.root, "config/adaptive_pay.yml"))).result)[rails_env.to_s]
      if config["retain_requests_for_test"] == true
        @retain_requests_for_test = true
      else
        set_environment config.delete("environment")
        config.each do |k, v|
          send "#{k}=", v
        end
      end
    end

    def set_environment(environment)
      @environment = environment.to_sym
      @base_url = {
        :production => "https://svcs.paypal.com/AdaptivePayments/",
        :sandbox => "https://svcs.sandbox.paypal.com/AdaptivePayments/",
        :beta_sandbox => "https://svcs.beta-sandbox.paypal.com/AdaptivePayments/"
      }[@environment]
    end

    def queue_requests_for_test?
      !!@queue_requests_for_test
    end

  end
end
<commit_msg>added some docs<commit_after>require "erb"

module AdaptivePay
  class Interface

    attr_accessor :base_url, :environment, :username, :password, :signature

    # Initialize a new interface object, takes an optional rails_env parameter
    # 
    # The rails_env parameter decides which configuration to load can be:
    #   nil -> use current Rails.env section in config/adaptive_pay.yml
    #   false -> dont load config from config/adaptive_pay.yml
    #   string/symbol -> use that section from config/adaptive_pay.yml
    def initialize(rails_env=nil)
      load(rails_env||Rails.env) unless rails_env == false
    end

    def load(rails_env)
      config = YAML.load(ERB.new(File.read(File.join(Rails.root, "config/adaptive_pay.yml"))).result)[rails_env.to_s]
      if config["retain_requests_for_test"] == true
        @retain_requests_for_test = true
      else
        set_environment config.delete("environment")
        config.each do |k, v|
          send "#{k}=", v
        end
      end
    end

    # Explicitly select a paypal environment to connect to
    # environment parameter can be :production, :sandbox, :beta_sandbox
    def set_environment(environment)
      @environment = environment.to_sym
      @base_url = {
        :production => "https://svcs.paypal.com/AdaptivePayments/",
        :sandbox => "https://svcs.sandbox.paypal.com/AdaptivePayments/",
        :beta_sandbox => "https://svcs.beta-sandbox.paypal.com/AdaptivePayments/"
      }[@environment]
    end

    def queue_requests_for_test?
      !!@queue_requests_for_test
    end

  end
end

{'fraction_non_alphanumeric': 0.10860578729800827, 'fraction_numerical': 0.0, 'mean_word_length': 3.0211480362537766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2948898', 'n_tokens_mistral': 891, 'n_tokens_neox': 833, 'n_words': 178}