module StackMob::Helpers
Public Instance Methods
sm_datastore()
click to toggle source
# File lib/stackmob/helpers.rb, line 17 def sm_datastore @sm_datastore ||= begin client = StackMob::Client.new(sm_api_host, sm_app_name, StackMob.env, StackMob.key, StackMob.secret) StackMob::DataStore.new(client) end end
sm_push()
click to toggle source
# File lib/stackmob/helpers.rb, line 24 def sm_push @sm_push ||= begin client = StackMob::Client.new(sm_push_host, sm_app_name, StackMob.env, StackMob.key, StackMob.secret) StackMob::Push.new(client) end end
Private Instance Methods
sm_api_host()
click to toggle source
# File lib/stackmob/helpers.rb, line 31 def sm_api_host sm_normalize_host(sm_hostname_from_header_or_config('HTTP_X_STACKMOB_API')) end
sm_app_name()
click to toggle source
# File lib/stackmob/helpers.rb, line 47 def sm_app_name StackMob.app_name end
sm_app_version()
click to toggle source
# File lib/stackmob/helpers.rb, line 52 def sm_app_version (Rails.env.production?) ? StackMob::PRODUCTION : StackMob::SANDBOX end
sm_hostname_from_header_or_config(header_str)
click to toggle source
# File lib/stackmob/helpers.rb, line 41 def sm_hostname_from_header_or_config(header_str) hostname = request.env[header_str] (hostname.nil? || hostname == "") ? StackMob.dev_url : [StackMob.client_name, hostname].join(".") end
sm_normalize_host(host_str)
click to toggle source
# File lib/stackmob/helpers.rb, line 57 def sm_normalize_host(host_str) schemeless = host_str.gsub(/^https?:\/\//, "") "http://#{schemeless}" end
sm_push_host()
click to toggle source
# File lib/stackmob/helpers.rb, line 36 def sm_push_host sm_normalize_host(sm_hostname_from_header_or_config('HTTP_X_STACKMOB_PUSH')) end