-
Notifications
You must be signed in to change notification settings - Fork 22
/
rails_helper.rb
40 lines (31 loc) · 937 Bytes
/
rails_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'action_view/base'
module Simplepay
module Helpers
##
# Adds helpers to your views for generating the correct HTML FORMs and
# valid signatures.
#
module RailsHelper
##
# This is the general interface for generating your Simple Pay service
# forms. See Simplepay::Services for available services and information
# specific to each.
#
# === Example
#
# (in your view)
#
# <%= simplepay_form_for(:service_name, {:attr => 'foo'}) %>
#
def simplepay_form_for(service_name, attributes = {})
service = get_simplepay_service(service_name)
service.form(attributes)
end
private
def get_simplepay_service(name) #:nodoc:
service = "Simplepay::Services::#{name.to_s.camelize}".constantize
service.new
end
end
end
end