Skip to content

Commit aca2843

Browse files
Wrap classes in on_load to eliminate autoload warning (#173)
1 parent 185d15e commit aca2843

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/logstasher.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,21 @@ def add_custom_fields(&block)
7171
LogStasher::CustomFields.add(*LogStasher.store.keys)
7272
instance_exec(fields, &block)
7373
end
74-
::ActionController::Metal.send(:define_method, :logstasher_add_custom_fields_to_payload, &wrapped_block)
75-
::ActionController::Base.send(:define_method, :logstasher_add_custom_fields_to_payload, &wrapped_block)
74+
::ActiveSupport.on_load(:action_controller) do
75+
::ActionController::Metal.send(:define_method, :logstasher_add_custom_fields_to_payload, &wrapped_block)
76+
::ActionController::Base.send(:define_method, :logstasher_add_custom_fields_to_payload, &wrapped_block)
77+
end
7678
end
7779

7880
def add_custom_fields_to_request_context(&block)
7981
wrapped_block = proc do |fields|
8082
instance_exec(fields, &block)
8183
LogStasher::CustomFields.add(*fields.keys)
8284
end
83-
::ActionController::Metal.send(:define_method, :logstasher_add_custom_fields_to_request_context, &wrapped_block)
84-
::ActionController::Base.send(:define_method, :logstasher_add_custom_fields_to_request_context, &wrapped_block)
85+
::ActiveSupport.on_load(:action_controller) do
86+
::ActionController::Metal.send(:define_method, :logstasher_add_custom_fields_to_request_context, &wrapped_block)
87+
::ActionController::Base.send(:define_method, :logstasher_add_custom_fields_to_request_context, &wrapped_block)
88+
end
8589
end
8690

8791
def add_default_fields_to_request_context(request)

0 commit comments

Comments
 (0)