Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent autoloading concerns #398

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/lhs/concerns/autoload_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.model_files
end

def self.require_direct_inheritance
model_files.map do |file|
model_files.sort.map do |file|
next unless File.read(file).match('LHS::Record')
require_dependency file
file.split('models/').last.gsub('.rb', '').classify
Expand All @@ -41,7 +41,9 @@ def self.require_direct_inheritance

def self.require_inheriting_records(parents)
model_files.each do |file|
next if parents.none? { |parent| File.read(file).match(/\b#{parent}\b/) }
file_content = File.read(file)
next if parents.none? { |parent| file_content.match(/\b#{parent}\b/) }
next if file_content.match?('extend ActiveSupport::Concern')
require_dependency file
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lhs/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module LHS
VERSION = '25.0.1'
VERSION = '25.0.2'
end
9 changes: 9 additions & 0 deletions spec/dummy/app/models/concerns/dummy_customer/some_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class DummyCustomer < Providers::CustomerSystem
module SomeConcern
extend ActiveSupport::Concern

# dont auto load this again with LHS as it would raise an exception
end
end
1 change: 1 addition & 0 deletions spec/dummy/app/models/dummy_customer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class DummyCustomer < Providers::CustomerSystem
include SomeConcern
endpoint 'http://customers'
endpoint 'http://customers/{id}'
end