Module: RailsStuff
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/rails_stuff.rb,
lib/rails_stuff/engine.rb,
lib/rails_stuff/helpers.rb,
lib/rails_stuff/version.rb,
lib/rails_stuff/responders.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/test_helpers.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/rspec_helpers.rb,
lib/rails_stuff/types_tracker.rb,
lib/rails_stuff/require_nested.rb,
lib/rails_stuff/transform_attrs.rb,
lib/rails_stuff/random_uniq_attr.rb,
lib/rails_stuff/helpers/bootstrap.rb,
lib/rails_stuff/statusable/helper.rb,
lib/rails_stuff/association_writer.rb,
lib/rails_stuff/statusable/builder.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/responders/turbolinks.rb,
lib/rails_stuff/test_helpers/response.rb,
lib/rails_stuff/rspec_helpers/signinable.rb,
lib/rails_stuff/statusable/mapped_helper.rb,
lib/rails_stuff/test_helpers/concurrency.rb,
lib/rails_stuff/rspec_helpers/concurrency.rb,
lib/rails_stuff/statusable/mapped_builder.rb,
lib/rails_stuff/resources_controller/actions.rb,
lib/rails_stuff/rspec_helpers/groups/feature.rb,
lib/rails_stuff/rspec_helpers/groups/request.rb,
lib/rails_stuff/resources_controller/belongs_to.rb,
lib/rails_stuff/resources_controller/sti_helpers.rb,
lib/rails_stuff/test_helpers/integration_session.rb,
lib/rails_stuff/resources_controller/basic_helpers.rb,
lib/rails_stuff/generators/concern/concern_generator.rb,
lib/rails_stuff/resources_controller/resource_helper.rb,
lib/rails_stuff/resources_controller/kaminari_helpers.rb,
lib/rails_stuff/resources_controller/has_scope_helpers.rb,
lib/rails_stuff/rspec_helpers/matchers/redirect_with_turbolinks.rb
Overview
Defined Under Namespace
Modules: AssociationWriter, Generators, Helpers, NullifyBlankAttrs, ParamsParser, RSpecHelpers, RandomUniqAttr, RedisStorage, RequireNested, ResourcesController, Responders, SortScope, Statusable, TestHelpers, TransformAttrs, TypesTracker, VERSION
Classes: Engine
Constant Summary
collapse
- MODULES =
rubocop:disable MutableConstant
{ require_nested: [:require, -> { RequireNested.setup }],
association_writer: :model,
nullify_blank_attrs: :model,
random_uniq_attr: :model,
statusable: :model,
transform_attrs: :model,
resources_controller: [
-> { defined?(::Responders) && :controller },
-> { ResourcesController.use_kaminari! if defined?(::Kaminari) },
],
sort_scope: -> { defined?(::HasScope) && :controller },
strong_parameters: -> { defined?(ActionController::Parameters) && :require },
url_for_keeping_params: -> { defined?(ActionDispatch::Routing) && :require },
}
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.base_controller ⇒ Object
29
30
31
|
# File 'lib/rails_stuff/engine.rb', line 29
def base_controller
@base_controller || ActionController::Base
end
|
.base_model ⇒ Object
33
34
35
|
# File 'lib/rails_stuff/engine.rb', line 33
def base_model
@base_model || ActiveRecord::Base
end
|
.load_modules ⇒ Object
Set it to array of modules to load.
RailsStuff.load_modules = [:statusable, :sort_scope]
25
26
27
|
# File 'lib/rails_stuff/engine.rb', line 25
def load_modules
@load_modules
end
|
Class Method Details
.deprecation_07 ⇒ Object
35
36
37
38
39
40
|
# File 'lib/rails_stuff.rb', line 35
def deprecation_07
@deprecation ||= begin
require 'active_support/deprecation'
ActiveSupport::Deprecation.new('0.7', 'RailsStuff')
end
end
|
.gem_version ⇒ Object
2
3
4
|
# File 'lib/rails_stuff/version.rb', line 2
def self.gem_version
Gem::Version.new VERSION::STRING
end
|
.rails4? ⇒ Boolean
31
32
33
|
# File 'lib/rails_stuff.rb', line 31
def rails4?
rails_version::MAJOR == 4
end
|
.rails_version ⇒ Object
27
28
29
|
# File 'lib/rails_stuff.rb', line 27
def rails_version
@rails_version = ActiveSupport::VERSION
end
|
.setup_modules! ⇒ Object
Extends base controller and model classes with modules. By default uses all modules. Use load_modules= to override this list.
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/rails_stuff/engine.rb', line 39
def setup_modules!
modules_to_load = load_modules || MODULES.keys
MODULES.slice(*modules_to_load).each do |m, (type, init)|
case type.respond_to?(:call) ? type.call : type
when :controller
RailsStuff.base_controller.extend const_get(m.to_s.camelize)
when :model
RailsStuff.base_model.extend const_get(m.to_s.camelize)
when :require
require "rails_stuff/#{m}"
end
init.try!(:call)
end
end
|