Class: BluePotionNet
Overview
Nice wrapper around VolleyWrapper, to use in BluePotion.
result that is returned has these attributes:
response
object
body
status_code
headers
not_modified?
success?
failure?
Class Method Summary collapse
- .build_shared(url, &block) ⇒ Object
- .delete(url, params, opts = {}, &block) ⇒ Object
- .get(url, params = {}, opts = {}, &block) ⇒ Object
- .get_json(url, params = {}, opts = {}, &block) ⇒ Object
- .is_shared? ⇒ Boolean
- .post(url, params, opts = {}, &block) ⇒ Object
- .put(url, params, opts = {}, &block) ⇒ Object
- .session ⇒ Object
- .session_client ⇒ Object
- .single_use_session ⇒ Object
Class Method Details
.build_shared(url, &block) ⇒ Object
70 71 72 |
# File 'lib/project/blue_potion_net.rb', line 70 def build_shared(url, &block) session_client.build_shared(PMApplication.current_application.context, url, &block) end |
.delete(url, params, opts = {}, &block) ⇒ Object
99 100 101 102 103 |
# File 'lib/project/blue_potion_net.rb', line 99 def delete(url, params, opts={}, &block) raise "[BluePotion error] You must provide a block when using app.net.delete" unless block ses = opts.delete(:session) || self.session ses.delete(url, params, opts, &block) end |
.get(url, params = {}, opts = {}, &block) ⇒ Object
74 75 76 77 78 |
# File 'lib/project/blue_potion_net.rb', line 74 def get(url, params={}, opts={}, &block) raise "[BluePotion error] You must provide a block when using app.net.get" unless block ses = opts.delete(:session) || self.session ses.get(url, params, opts, &block) end |
.get_json(url, params = {}, opts = {}, &block) ⇒ Object
80 81 82 83 84 85 |
# File 'lib/project/blue_potion_net.rb', line 80 def get_json(url, params={}, opts={}, &block) raise "[BluePotion error] You must provide a block when using app.net.get_json" unless block ses = opts.delete(:session) || self.session opts[:serializer] = :json ses.get(url, params, opts, &block) end |
.is_shared? ⇒ Boolean
62 63 64 |
# File 'lib/project/blue_potion_net.rb', line 62 def is_shared? !session_client.shared.is_nil? end |
.post(url, params, opts = {}, &block) ⇒ Object
87 88 89 90 91 |
# File 'lib/project/blue_potion_net.rb', line 87 def post(url, params, opts={}, &block) raise "[BluePotion error] You must provide a block when using app.net.post" unless block ses = opts.delete(:session) || self.session ses.post(url, params, opts, &block) end |
.put(url, params, opts = {}, &block) ⇒ Object
93 94 95 96 97 |
# File 'lib/project/blue_potion_net.rb', line 93 def put(url, params, opts={}, &block) raise "[BluePotion error] You must provide a block when using app.net.put" unless block ses = opts.delete(:session) || self.session ses.put(url, params, opts, &block) end |
.session ⇒ Object
58 59 60 |
# File 'lib/project/blue_potion_net.rb', line 58 def session session_client.shared ? session_client.shared : single_use_session end |
.session_client ⇒ Object
54 55 56 |
# File 'lib/project/blue_potion_net.rb', line 54 def session_client @_session_client ||= VW::SessionClient end |
.single_use_session ⇒ Object
66 67 68 |
# File 'lib/project/blue_potion_net.rb', line 66 def single_use_session session_client.new(PMApplication.current_application.context, "") end |