Module: RailsStuff
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/rails_stuff.rb,
lib/rails_stuff/helpers.rb,
lib/rails_stuff/railtie.rb,
lib/rails_stuff/version.rb,
lib/rails_stuff/sort_scope.rb,
lib/rails_stuff/statusable.rb,
lib/rails_stuff/helpers/all.rb,
lib/rails_stuff/helpers/text.rb,
lib/rails_stuff/helpers/forms.rb,
lib/rails_stuff/helpers/links.rb,
lib/rails_stuff/params_parser.rb,
lib/rails_stuff/redis_storage.rb,
lib/rails_stuff/types_tracker.rb,
lib/rails_stuff/random_uniq_attr.rb,
lib/rails_stuff/helpers/bootstrap.rb,
lib/rails_stuff/helpers/translation.rb,
lib/rails_stuff/nullify_blank_attrs.rb,
lib/rails_stuff/resources_controller.rb,
lib/rails_stuff/helpers/resource_form.rb,
lib/rails_stuff/test_helpers/response.rb,
lib/rails_stuff/resources_controller/actions.rb,
lib/rails_stuff/resources_controller/responder.rb,
lib/rails_stuff/resources_controller/sti_helpers.rb,
lib/rails_stuff/resources_controller/basic_helpers.rb,
lib/rails_stuff/resources_controller/resource_helper.rb
Overview
Useful stuff for Rails.
Defined Under Namespace
Modules: Helpers, NullifyBlankAttrs, ParamsParser, RandomUniqAttr, RedisStorage, ResourcesController, SortScope, Statusable, TestHelpers, TypesTracker, VERSION Classes: Railtie
Constant Summary collapse
- MODULES =
{ nullify_blank_attrs: :model, random_uniq_attr: :model, statusable: :model, resources_controller: [ :controller, -> { ResourcesController.kaminari! if defined?(::Kaminari) }, ], sort_scope: -> { defined?(::HasScope) && :controller }, }
Class Attribute Summary collapse
- .base_controller ⇒ Object
- .base_model ⇒ Object
-
.load_modules ⇒ Object
Set it to array of modules to load.
Class Method Summary collapse
- .gem_version ⇒ Object
-
.setup_modules! ⇒ Object
Extends base controller and model classes with modules.
Class Attribute Details
.base_controller ⇒ Object
24 25 26 |
# File 'lib/rails_stuff/railtie.rb', line 24 def base_controller @base_controller || ActionController::Base end |
.base_model ⇒ Object
28 29 30 |
# File 'lib/rails_stuff/railtie.rb', line 28 def base_model @base_model || ActiveRecord::Base end |
.load_modules ⇒ Object
Set it to array of modules to load.
# config/initializers/rails_stuff.rb
RailsStuff.load_modules = [:statusable, :sort_scope]
20 21 22 |
# File 'lib/rails_stuff/railtie.rb', line 20 def load_modules @load_modules end |
Class Method Details
.gem_version ⇒ Object
2 3 4 |
# File 'lib/rails_stuff/version.rb', line 2 def self.gem_version Gem::Version.new VERSION::STRING end |
.setup_modules! ⇒ Object
Extends base controller and model classes with modules. By default uses all modules. Use load_modules= to override this list.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rails_stuff/railtie.rb', line 34 def setup_modules! modules_to_load = load_modules || MODULES.keys MODULES.slice(*modules_to_load).each do |m, (type, init)| m = const_get m.to_s.camelize case type.respond_to?(:call) ? type.call : type when :controller RailsStuff.base_controller.extend m when :model RailsStuff.base_model.extend m end init.try!(:call) end end |