Module: Motr
- Defined in:
- lib/motr/modding.rb,
lib/motr.rb,
lib/motr/dash.rb,
lib/motr/mods.rb,
lib/motr/forms.rb,
lib/motr/rails.rb,
lib/motr/version.rb,
lib/motr/forms/base.rb,
lib/motr/orm/mongoid.rb,
lib/motr/forms/builder.rb,
lib/motr/forms/helpers.rb,
lib/motr/mods/scopeable.rb,
lib/motr/mods/sluggable.rb,
lib/motr/helpers/elements.rb,
lib/motr/errors/motr_error.rb,
lib/motr/orm/active_record.rb,
lib/motr/controller/helpers.rb,
lib/motr/helpers/navigation.rb,
lib/motr/controller/responder.rb,
lib/motr/errors/module_missing.rb,
lib/motr/errors/invalid_options.rb,
lib/motr/helpers/layout_helpers.rb,
lib/generators/motr/motr_generator.rb,
lib/generators/motr/compass_generator.rb,
lib/generators/motr/install_generator.rb
Overview
:nodoc
Defined Under Namespace
Modules: Controller, Dash, Errors, Forms, Generators, Helpers, Modding, Mods, Orm Classes: Engine
Constant Summary collapse
- VERSION =
"0.1.1".freeze
- @@applied_mods =
ActiveSupport::OrderedHash.new
Class Method Summary collapse
-
.add_mod(mod_name, options = {}) ⇒ Object
Enable autoloading of mods.
-
.apply_helpers(helper_name) ⇒ Object
Apply helpers from mods at load time.
-
.configure {|_self| ... } ⇒ Object
Support initializer configuration.
-
.track_mod(mod_name, ref) ⇒ Object
Tracks which models have been modded by any given mod, providing an easy way to do lookups.
Class Method Details
.add_mod(mod_name, options = {}) ⇒ Object
Enable autoloading of mods
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/motr.rb', line 41 def self.add_mod(mod_name, = {}) const_name = ActiveSupport::Inflector.camelize(mod_name.to_s) mod_name_pl = ActiveSupport::Inflector.pluralize(mod_name.to_s) # Setup a tracking array self.applied_mods[mod_name] ||= [] if autoload_path = .delete(:autoload) path = (autoload_path == true ? "motr/mods/#{mod_name.to_s}" : autoload_path) Motr::Mods.send(:autoload, const_name, path) end end |
.apply_helpers(helper_name) ⇒ Object
Apply helpers from mods at load time.
70 71 72 73 74 |
# File 'lib/motr.rb', line 70 def self.apply_helpers(helper_name) ActiveSupport.on_load(:action_controller) do include helper_name end end |
.configure {|_self| ... } ⇒ Object
Support initializer configuration
79 80 81 |
# File 'lib/motr.rb', line 79 def self.configure #:nodoc: yield self end |
.track_mod(mod_name, ref) ⇒ Object
Tracks which models have been modded by any given mod, providing an easy way to do lookups.
62 63 64 |
# File 'lib/motr.rb', line 62 def self.track_mod(mod_name, ref) self.applied_mods[mod_name.to_sym] |= [ ActiveSupport::Inflector.camelize(ref.to_s) ] end |