Module: Constellation::Base::ObjectExtensions::ObjectClassMethods
- Defined in:
- lib/constellation/base/object_extensions.rb
Instance Method Summary collapse
-
#include_constellation(options = {}) ⇒ Object
This method is to be used inside a class in your RAILS_ROOT/app with which you would like to extend the Constellation-provided functionality rather than completely replace it.
Instance Method Details
#include_constellation(options = {}) ⇒ Object
This method is to be used inside a class in your RAILS_ROOT/app with which you would like to extend the Constellation-provided functionality rather than completely replace it.
Usage:
include_constellation
include_constellation :only => [:cms, :commerce]
include_constellation :except => :cms
When used without any arguments, this method requires all of the loaded Constellation modules’ classes that match the current class name. Use :only or :except to restrict which modules’ classes you wish to require.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/constellation/base/object_extensions.rb', line 22 def include_constellation(={}) modules = [:authentication, :authorization, :admin, :workflow, :cms, :commerce] if [:only] modules = [:only].is_a?(Array) ? [:only] : [[:only]] elsif [:except] [:except] = [[:except]] unless [:except].is_a? Array modules.reject!{ |x| [:except].include?(x) } end filename = self.name.underscore found = false modules.each do |m| if Rails.application.config.constellation.include? m root = Rails.application.config.constellation.send(m).root ["/lib/", "/app/controllers/", "/app/models/", "/app/mailers/"].each do |path| begin require_dependency root + path + filename found = true rescue LoadError end end end end # TODO: Refer to a FAQ or Guide entry raise LoadError.new "Could not find any Constellation provided files to include! Have you required the gems?" unless found end |