Class: PhraseApp::ParamsHelpers::BodyTypeHelper
- Inherits:
-
Object
- Object
- PhraseApp::ParamsHelpers::BodyTypeHelper
- Defined in:
- lib/phraseapp-ruby.rb
Instance Method Summary collapse
- #body ⇒ Object
- #ctype ⇒ Object
-
#initialize(data_hash, post_body = nil) ⇒ BodyTypeHelper
constructor
A new instance of BodyTypeHelper.
Constructor Details
#initialize(data_hash, post_body = nil) ⇒ BodyTypeHelper
Returns a new instance of BodyTypeHelper.
1556 1557 1558 1559 |
# File 'lib/phraseapp-ruby.rb', line 1556 def initialize(data_hash, post_body=nil) @data_hash = data_hash @post_body = post_body end |
Instance Method Details
#body ⇒ Object
1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 |
# File 'lib/phraseapp-ruby.rb', line 1561 def body if @post_body != nil body = @post_body.join+PhraseApp.multipart(@data_hash) body << "--#{PhraseApp::MULTIPART_BOUNDARY}--\r\n" elsif defined?(@data_hash) && @data_hash.is_a?(Hash) && @data_hash.keys.any? JSON.dump(@data_hash) else nil end end |
#ctype ⇒ Object
1572 1573 1574 1575 1576 1577 1578 1579 1580 |
# File 'lib/phraseapp-ruby.rb', line 1572 def ctype if @post_body != nil return "multipart/form-data; boundary=#{PhraseApp::MULTIPART_BOUNDARY}" elsif defined?(@data_hash) && @data_hash.is_a?(Hash) && @data_hash.keys.any? return "application/json" else return "" end end |