Class: Paysio::Form
- Inherits:
-
Object
- Object
- Paysio::Form
- Defined in:
- lib/paysio/form.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#html_options ⇒ Object
Returns the value of attribute html_options.
-
#params ⇒ Object
Returns the value of attribute params.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #add_params(params = {}) ⇒ Object
-
#initialize(params = {}) ⇒ Form
constructor
A new instance of Form.
- #render ⇒ Object
- #render_html ⇒ Object
- #render_javascript ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Form
Returns a new instance of Form.
5 6 7 8 9 10 |
# File 'lib/paysio/form.rb', line 5 def initialize(params = {}) @params = params @values = {} @errors = {} @html_options = {} end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
3 4 5 |
# File 'lib/paysio/form.rb', line 3 def errors @errors end |
#html_options ⇒ Object
Returns the value of attribute html_options.
3 4 5 |
# File 'lib/paysio/form.rb', line 3 def @html_options end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/paysio/form.rb', line 3 def params @params end |
#values ⇒ Object
Returns the value of attribute values.
3 4 5 |
# File 'lib/paysio/form.rb', line 3 def values @values end |
Instance Method Details
#add_params(params = {}) ⇒ Object
12 13 14 |
# File 'lib/paysio/form.rb', line 12 def add_params(params = {}) self.params.merge!(params) end |
#render ⇒ Object
16 17 18 |
# File 'lib/paysio/form.rb', line 16 def render "#{render_html} #{render_javascript}".html_safe end |
#render_html ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/paysio/form.rb', line 30 def render_html html = <<-TEXT <form id="#{[:id] || 'paysio'}" class="#{[:class]}" action="#{[:action] || '#'}" method="#{([:method] || 'post').upcase}" ></form> TEXT end |
#render_javascript ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/paysio/form.rb', line 20 def render_javascript html = <<-TEXT <script type="text/javascript"> Paysio.setEndpoint('#{Paysio.api_url}'); Paysio.setPublishableKey("#{Paysio.publishable_key}"); Paysio.form.build(#{javascript_form_params}); </script> TEXT end |