Module: Adva
- Defined in:
- lib/adva/registry.rb,
lib/adva.rb,
lib/adva/core.rb,
lib/adva/rack.rb,
lib/adva/view.rb,
lib/adva/engine.rb,
lib/adva/testing.rb,
lib/adva/responder.rb,
lib/adva/view/form.rb,
lib/adva/view/menu.rb,
lib/adva/view/tabs.rb,
lib/adva/controller.rb,
lib/adva/generators.rb,
lib/adva/tasks/core.rb,
lib/adva/rack/static.rb,
lib/adva/generators/app.rb,
lib/adva/testing/engine.rb,
lib/adva/view/form/tabs.rb,
lib/adva/view/menu/admin.rb,
lib/adva/view/menu/items.rb,
lib/adva/generators/engine.rb,
lib/adva/generators/gemfile.rb,
lib/adva/generators/install.rb,
lib/adva/responder/redirect.rb,
lib/adva/controller/references.rb,
lib/adva/controller/abstract_actions.rb,
lib/adva/controller/internal_redirect.rb
Overview
Internally redirects a request to another controller. This is used by the abstract_actions module.
Defined Under Namespace
Modules: Controller, Engine, Generators, Rack, Tasks, Testing, View Classes: Core, Registry, Responder
Class Method Summary collapse
- .engine(name) ⇒ Object
- .engine?(name) ⇒ Boolean (also: installed?)
- .engine_names ⇒ Object
- .engines ⇒ Object
- .loaded_slices ⇒ Object
-
.slice(path_with_namespace, &block) ⇒ Object
Helps you slice and dice your addons to adva-cms.
Class Method Details
.engine(name) ⇒ Object
24 25 26 27 |
# File 'lib/adva.rb', line 24 def engine(name) name = "Adva::#{name.camelize}" unless name.to_s.starts_with?('Adva::') engines.detect { |engine| engine.name == name } end |
.engine?(name) ⇒ Boolean Also known as: installed?
33 34 35 |
# File 'lib/adva.rb', line 33 def engine?(name) engine_names.include?(name) end |
.engine_names ⇒ Object
29 30 31 |
# File 'lib/adva.rb', line 29 def engine_names @engine_names ||= engines.map { |constant| constant.name.split('::').last.underscore.to_sym } end |
.engines ⇒ Object
17 18 19 20 21 22 |
# File 'lib/adva.rb', line 17 def engines @engines ||= constants.map do |name| constant = const_get(name) constant if constant != Adva::Core && constant.is_a?(Class) && constant < ::Rails::Engine end.compact.sort { |lft, rgt| lft.name <=> rgt.name }.unshift(Adva::Core) end |
.loaded_slices ⇒ Object
75 76 77 |
# File 'lib/adva.rb', line 75 def loaded_slices @loaded_slices ||= Set.new end |
.slice(path_with_namespace, &block) ⇒ Object
Helps you slice and dice your addons to adva-cms
load and slice (patch) the class Existing::Stuff
in ‘ur/engine/existing/stuff_slice.rb’ Adva.slice ‘existing/stuff’ do
include do
def fn0rd
23 + 42
end
end
attr_accessor :things
end
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/adva.rb', line 50 def slice(path_with_namespace, &block) raise ArgumentError, 'must give block to slice and dice' unless block_given? if path_with_namespace =~ /^([^#]+)#([^#]+)$/ path, namespace = $1, $2 else raise ArgumentError, "first argument must be class_to_slice#your_slice_identifier" end unless loaded_slices.include?(path_with_namespace) class_name = path.sub(/\.\w+$/,'').pluralize.classify # cut out extension for minimal templates begin class_name.constantize.class_eval(&block) rescue NameError => e if e..include?(class_name) require_dependency(path) else raise e end ensure loaded_slices << path_with_namespace end else Rails.logger.debug { "Adva.slice: already loaded #{path_with_namespace}, skipping" } end end |