Class: RulesIO::Rack
Direct Known Subclasses
Constant Summary collapse
- @@config_options =
cattr_accessor :config_options
{}
Instance Attribute Summary collapse
-
#config_options ⇒ Object
Returns the value of attribute config_options.
-
#controller_data ⇒ Object
Returns the value of attribute controller_data.
-
#filter_parameters ⇒ Object
Returns the value of attribute filter_parameters.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #default_ignored_crawlers ⇒ Object
- #flush(env = {}) ⇒ Object
-
#initialize(app, options = {}) ⇒ Rack
constructor
A new instance of Rack.
- #send_event(event) ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Rack
Returns a new instance of Rack.
20 21 22 23 24 25 26 27 28 |
# File 'lib/rulesio/rack.rb', line 20 def initialize(app, ={}) self.class. = @config_options = ( || {}) RulesIO.instance = self @app = app @buffer = [] @filter_parameters ||= defined?(Rails) ? Rails.application.config.filter_parameters : [] @token = [:token] @controller_data = [:controller_data] || '{}' end |
Instance Attribute Details
#config_options ⇒ Object
Returns the value of attribute config_options.
3 4 5 |
# File 'lib/rulesio/rack.rb', line 3 def @config_options end |
#controller_data ⇒ Object
Returns the value of attribute controller_data.
3 4 5 |
# File 'lib/rulesio/rack.rb', line 3 def controller_data @controller_data end |
#filter_parameters ⇒ Object
Returns the value of attribute filter_parameters.
3 4 5 |
# File 'lib/rulesio/rack.rb', line 3 def filter_parameters @filter_parameters end |
Class Method Details
.config_options ⇒ Object
8 9 10 |
# File 'lib/rulesio/rack.rb', line 8 def self. @@config_options end |
.config_options=(opts) ⇒ Object
12 13 14 |
# File 'lib/rulesio/rack.rb', line 12 def self.(opts) @@config_options = opts end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rulesio/rack.rb', line 30 def call(env) @buffer = [] request = ::Rack::Request.new(env) env['rulesio.request_url'] = request.url env['rulesio.request_method'] = request.request_method @app.call(env) ensure flush(env) end |
#default_ignored_crawlers ⇒ Object
16 17 18 |
# File 'lib/rulesio/rack.rb', line 16 def default_ignored_crawlers %w(Baidu Gigabot Googlebot libwww-perl lwp-trivial msnbot SiteUptime Slurp WordPress ZIBB ZyBorg Yandex Jyxobot Huaweisymantecspider ApptusBot NewRelicPinger CopperEgg Pingdom UptimeRobot) end |
#flush(env = {}) ⇒ Object
44 45 46 47 48 |
# File 'lib/rulesio/rack.rb', line 44 def flush(env={}) return if (events = @buffer).empty? @buffer = [] RulesIO.queue.push(:token => @token, :payload => events.map {|event| prepare_event(event, env)}) end |
#send_event(event) ⇒ Object
40 41 42 |
# File 'lib/rulesio/rack.rb', line 40 def send_event(event) @buffer << event end |