Module: ColumnsTrace
- Defined in:
- lib/columns_trace.rb,
lib/columns_trace/railtie.rb,
lib/columns_trace/version.rb,
lib/columns_trace/registry.rb,
lib/columns_trace/log_reporter.rb,
lib/columns_trace/created_record.rb,
lib/columns_trace/rails_integration.rb,
lib/columns_trace/sidekiq_integration.rb
Defined Under Namespace
Modules: Registry Classes: CreatedRecord, LogReporter, Railtie, SidekiqMiddleware
Constant Summary collapse
- VERSION =
"0.3.1"
Class Attribute Summary collapse
- .backtrace_cleaner ⇒ Object
-
.ignored_columns ⇒ Object
Configures columns that will be ignored.
- .ignored_models ⇒ Object
-
.reporter ⇒ Object
Allows to set the reporter.
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
A convenient method to configure this gem.
-
.enable_sidekiq_tracing! ⇒ Object
Enables integration with Sidekiq, which is disabled by default.
- .ignored_column?(model, column) ⇒ Boolean
- .ignored_model?(model) ⇒ Boolean
-
.report(title) ⇒ Object
Manually trace columns usage in an arbitrary code.
Class Attribute Details
.backtrace_cleaner ⇒ Object
82 83 84 |
# File 'lib/columns_trace.rb', line 82 def backtrace_cleaner @backtrace_cleaner end |
.ignored_columns ⇒ Object
Configures columns that will be ignored.
58 59 60 |
# File 'lib/columns_trace.rb', line 58 def ignored_columns @ignored_columns end |
.ignored_models ⇒ Object
32 33 34 |
# File 'lib/columns_trace.rb', line 32 def ignored_models @ignored_models end |
.reporter ⇒ Object
Allows to set the reporter. Defaults to log reporter that outputs to ‘log/columns_trace.log` file when inside a rails application.
79 80 81 |
# File 'lib/columns_trace.rb', line 79 def reporter @reporter end |
Class Method Details
.configure {|_self| ... } ⇒ Object
A convenient method to configure this gem.
110 111 112 |
# File 'lib/columns_trace.rb', line 110 def configure yield self end |
.enable_sidekiq_tracing! ⇒ Object
Enables integration with Sidekiq, which is disabled by default.
98 99 100 101 |
# File 'lib/columns_trace.rb', line 98 def enable_sidekiq_tracing! require_relative "columns_trace/sidekiq_integration" true end |
.ignored_column?(model, column) ⇒ Boolean
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/columns_trace.rb', line 61 def ignored_column?(model, column) ignored_columns.any? do |value| if value.is_a?(Hash) columns = value[model] || value[model.name] || value[model.name.to_sym] if columns columns = Array(columns).map(&:to_s) columns.include?(column) end else value.to_s == column end end end |
.ignored_model?(model) ⇒ Boolean
47 48 49 |
# File 'lib/columns_trace.rb', line 47 def ignored_model?(model) ignored_models.include?(model) end |
.report(title) ⇒ Object
Manually trace columns usage in an arbitrary code.
25 26 27 28 29 |
# File 'lib/columns_trace.rb', line 25 def report(title) Registry.clear yield reporter.report(title, Registry.created_records) end |