Module: PayPal::Recurring::Utils

Included in:
Notification, Response::Base
Defined in:
lib/paypal/recurring/utils.rb

Instance Method Summary collapse

Instance Method Details

#convert_to_time(string) ⇒ Object



4
5
6
# File 'lib/paypal/recurring/utils.rb', line 4

def convert_to_time(string)
  DateTime.strptime(string, "%H:%M:%S %b %e, %Y %Z").new_offset(0)
end

#mapping(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/paypal/recurring/utils.rb', line 8

def mapping(options = {})
  options.each do |to, from|
    class_eval <<-RUBY
      def #{to}
        @#{to} ||= begin
          from = [#{from.inspect}].flatten
          name = from.find {|name| params[name]}
          value = nil
          value = params[name] if name
          value = send("build_#{to}", value) if respond_to?("build_#{to}", true)
          value
        end
      end
    RUBY
  end
end