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

Setup zeitwerk #107

Merged
merged 4 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Setup zeitwerk
  • Loading branch information
Spone committed Feb 23, 2022
commit 22c3d119fca1d3fa65689e3b9feb0a0ffcba2ccf
5 changes: 1 addition & 4 deletions app/components/view_component/form/base_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ class << self
attr_accessor :default_options
end

if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("6.1")
require "view_component/form/class_names_helper"
include ClassNamesHelper
end
include ClassNamesHelper if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("6.1")

attr_reader :form, :object_name, :options

Expand Down
11 changes: 9 additions & 2 deletions lib/view_component/form.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# frozen_string_literal: true

require_relative "form/version"
require "view_component"
require "zeitwerk"

loader = Zeitwerk::Loader.for_gem
form = "#{__dir__}/form.rb"
loader.ignore(form)
loader.push_dir("#{__dir__}/form", namespace: ViewComponent::Form)
loader.setup

require_relative "form/engine"
require_relative "form/builder"
2 changes: 0 additions & 2 deletions lib/view_component/form/builder.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "action_view"

module ViewComponent
module Form
class Builder < ActionView::Helpers::FormBuilder
Expand Down
2 changes: 0 additions & 2 deletions lib/view_component/form/engine.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "rails/engine"

module ViewComponent
module Form
# :nodoc:
Expand Down
1 change: 1 addition & 0 deletions view_component-form.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "actionview", [">= 6.0.0", "< 7.1"]
spec.add_dependency "activesupport", [">= 6.0.0", "< 7.1"]
spec.add_dependency "view_component", [">= 2.34.0", "< 3.0"]
spec.add_dependency "zeitwerk", ["~> 2.5"]
end