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.
992 993 994 995 |
# File 'lib/phraseapp-ruby.rb', line 992 def initialize(data_hash, post_body=nil) @data_hash = data_hash @post_body = post_body end |
Instance Method Details
#body ⇒ Object
997 998 999 1000 1001 1002 1003 1004 1005 1006 |
# File 'lib/phraseapp-ruby.rb', line 997 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
1008 1009 1010 1011 1012 1013 1014 1015 1016 |
# File 'lib/phraseapp-ruby.rb', line 1008 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 |