Class: InformantRails::Client
- Inherits:
-
Object
- Object
- InformantRails::Client
- Defined in:
- lib/informant-rails/client.rb
Class Method Summary collapse
- .cleanup ⇒ Object
- .process ⇒ Object
- .record(env) ⇒ Object
- .record_action(controller_name, action) ⇒ Object
- .record_validated_model(model) ⇒ Object
- .request ⇒ Object
- .transmit(completed_request) ⇒ Object
Class Method Details
.cleanup ⇒ Object
34 35 36 |
# File 'lib/informant-rails/client.rb', line 34 def self.cleanup Thread.current[:informant_request] = nil end |
.process ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/informant-rails/client.rb', line 21 def self.process if request && request.models.any? this_request = request Thread.new { transmit(this_request) } end ensure cleanup end |
.record(env) ⇒ Object
4 5 6 7 8 |
# File 'lib/informant-rails/client.rb', line 4 def self.record(env) unless Config.api_token.blank? || env['REQUEST_METHOD'] == 'GET' new_request.request_url = env['HTTP_REFERER'] end end |
.record_action(controller_name, action) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/informant-rails/client.rb', line 10 def self.record_action(controller_name, action) if request request.filename = controller_name request.action = action end end |
.record_validated_model(model) ⇒ Object
17 18 19 |
# File 'lib/informant-rails/client.rb', line 17 def self.record_validated_model(model) request.process_model(model) if request && include_model?(model) end |
.request ⇒ Object
30 31 32 |
# File 'lib/informant-rails/client.rb', line 30 def self.request Thread.current[:informant_request] end |
.transmit(completed_request) ⇒ Object
38 39 40 41 42 |
# File 'lib/informant-rails/client.rb', line 38 def self.transmit(completed_request) Net::HTTP.start(api_endpoint.host, api_endpoint.port, use_ssl: api_endpoint.scheme == 'https') do |http| http.request(net_http_post_request(completed_request)) end end |