Module: RailsAdminImport::Config
- Defined in:
- lib/rails_admin_import/config.rb,
lib/rails_admin_import/config/base.rb,
lib/rails_admin_import/config/model.rb
Defined Under Namespace
Class Attribute Summary collapse
-
.line_item_limit ⇒ Object
Returns the value of attribute line_item_limit.
-
.logging ⇒ Object
Returns the value of attribute logging.
-
.registry ⇒ Object
readonly
Stores model configuration objects in a hash identified by model’s class name.
Class Method Summary collapse
-
.model(entity, &block) ⇒ Object
Loads a model configuration instance from the registry or registers a new one if one is yet to be added.
-
.reset ⇒ Object
Reset all configurations to defaults.
-
.reset_model(model) ⇒ Object
Reset a provided model’s configuration.
Class Attribute Details
.line_item_limit ⇒ Object
Returns the value of attribute line_item_limit.
13 14 15 |
# File 'lib/rails_admin_import/config.rb', line 13 def line_item_limit @line_item_limit end |
.logging ⇒ Object
Returns the value of attribute logging.
12 13 14 |
# File 'lib/rails_admin_import/config.rb', line 12 def logging @logging end |
.registry ⇒ Object (readonly)
Stores model configuration objects in a hash identified by model’s class name.
11 12 13 |
# File 'lib/rails_admin_import/config.rb', line 11 def registry @registry end |
Class Method Details
.model(entity, &block) ⇒ Object
Loads a model configuration instance from the registry or registers a new one if one is yet to be added.
First argument can be an instance of requested model, its class object, its class name as a string or symbol or a RailsAdminImport::AbstractModel instance.
If a block is given it is evaluated in the context of configuration instance.
Returns given model’s configuration
27 28 29 30 31 32 33 |
# File 'lib/rails_admin_import/config.rb', line 27 def model(entity, &block) key = entity.name.to_sym config = @registry[key] ||= RailsAdminImport::Config::Model.new(entity) config.instance_eval(&block) if block config end |
.reset ⇒ Object
Reset all configurations to defaults.
38 39 40 41 42 |
# File 'lib/rails_admin_import/config.rb', line 38 def reset @registry = {} @logging = false @line_item_limit = 1000 end |
.reset_model(model) ⇒ Object
Reset a provided model’s configuration.
47 48 49 50 |
# File 'lib/rails_admin_import/config.rb', line 47 def reset_model(model) key = model.kind_of?(Class) ? model.name.to_sym : model.to_sym @registry.delete(key) end |