Using the new eager load API from Rails 4

Closes #478
This commit is contained in:
Rafael Mendonça França 2013-01-02 13:11:46 -03:00
parent cae72bfca8
commit 2967fbbf85
4 changed files with 59 additions and 35 deletions

View File

@ -6,14 +6,25 @@ require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/hash/reverse_merge'
module SimpleForm
autoload :Components, 'simple_form/components'
autoload :ErrorNotification, 'simple_form/error_notification'
autoload :FormBuilder, 'simple_form/form_builder'
autoload :Helpers, 'simple_form/helpers'
autoload :I18nCache, 'simple_form/i18n_cache'
autoload :Inputs, 'simple_form/inputs'
autoload :MapType, 'simple_form/map_type'
autoload :Wrappers, 'simple_form/wrappers'
extend ActiveSupport::Autoload
autoload :Helpers
autoload :Wrappers
eager_autoload do
autoload :Components
autoload :ErrorNotification
autoload :FormBuilder
autoload :I18nCache
autoload :Inputs
autoload :MapType
end
def self.eager_load!
super
SimpleForm::Inputs.eager_load!
SimpleForm::Components.eager_load!
end
## CONFIGURATION OPTIONS
@ -195,3 +206,5 @@ module SimpleForm
yield self
end
end
require 'simple_form/railtie' if defined?(Rails)

View File

@ -6,15 +6,17 @@ module SimpleForm
# to the input in order to be enabled. On the other hand, things like
# hints can generate output automatically by doing I18n lookups.
module Components
autoload :Errors, 'simple_form/components/errors'
autoload :Hints, 'simple_form/components/hints'
autoload :HTML5, 'simple_form/components/html5'
autoload :LabelInput, 'simple_form/components/label_input'
autoload :Labels, 'simple_form/components/labels'
autoload :MinMax, 'simple_form/components/min_max'
autoload :Maxlength, 'simple_form/components/maxlength'
autoload :Pattern, 'simple_form/components/pattern'
autoload :Placeholders, 'simple_form/components/placeholders'
autoload :Readonly, 'simple_form/components/readonly'
extend ActiveSupport::Autoload
autoload :Errors
autoload :Hints
autoload :HTML5
autoload :LabelInput
autoload :Labels
autoload :MinMax
autoload :Maxlength
autoload :Pattern
autoload :Placeholders
autoload :Readonly
end
end

View File

@ -1,21 +1,23 @@
module SimpleForm
module Inputs
autoload :Base, 'simple_form/inputs/base'
autoload :BlockInput, 'simple_form/inputs/block_input'
autoload :BooleanInput, 'simple_form/inputs/boolean_input'
autoload :CollectionCheckBoxesInput, 'simple_form/inputs/collection_check_boxes_input'
autoload :CollectionInput, 'simple_form/inputs/collection_input'
autoload :CollectionRadioButtonsInput, 'simple_form/inputs/collection_radio_buttons_input'
autoload :CollectionSelectInput, 'simple_form/inputs/collection_select_input'
autoload :DateTimeInput, 'simple_form/inputs/date_time_input'
autoload :FileInput, 'simple_form/inputs/file_input'
autoload :GroupedCollectionSelectInput, 'simple_form/inputs/grouped_collection_select_input'
autoload :HiddenInput, 'simple_form/inputs/hidden_input'
autoload :NumericInput, 'simple_form/inputs/numeric_input'
autoload :PasswordInput, 'simple_form/inputs/password_input'
autoload :PriorityInput, 'simple_form/inputs/priority_input'
autoload :RangeInput, 'simple_form/inputs/range_input'
autoload :StringInput, 'simple_form/inputs/string_input'
autoload :TextInput, 'simple_form/inputs/text_input'
extend ActiveSupport::Autoload
autoload :Base
autoload :BlockInput
autoload :BooleanInput
autoload :CollectionCheckBoxesInput
autoload :CollectionInput
autoload :CollectionRadioButtonsInput
autoload :CollectionSelectInput
autoload :DateTimeInput
autoload :FileInput
autoload :GroupedCollectionSelectInput
autoload :HiddenInput
autoload :NumericInput
autoload :PasswordInput
autoload :PriorityInput
autoload :RangeInput
autoload :StringInput
autoload :TextInput
end
end

View File

@ -0,0 +1,7 @@
require 'rails/railtie'
module SimpleForm
class Railtie < Rails::Railtie
config.eager_load_namespaces << SimpleForm
end
end