Module: Extensions

Defined in:
lib/extensions.rb

Defined Under Namespace

Modules: ActionMailerSuppression, ActsAsHelpers, AfterCommitAction, AssociationInverseSuppression, Attachable, Conditional, CoreExtensions, DatabaseEvent, DateTimeHelpers, DeferredWorkflowStatePersistence, DestroyCallbacks, DeviseAsyncEmail, DiscussionTopic, HasManyInverseThrough, HighVoltagePageActionClass, InheritedNestedLayouts, Legacy, Materials, PathnameHelpers, PolyglotWithDatabase, RenderCollectionWithPrefixSuffix, RenderWithinLayout, TimeBoundedRecord

Constant Summary collapse

EXTENSIONS_PATH =
"#{__dir__}/extensions"

Class Method Summary collapse

Class Method Details

.load(module_) ⇒ void

This method returns an undefined value.

Loads the given extension.

Extensions are prefixed with the +Extensions::Feature+ namespace, and mirrors the global class hierarchy. Therefore, if a feature is called 'Awesome', and needs to extend +ActiveRecord::Base+, then its methods should be in +Extensions::Awesome::ActiveRecord::Base+.

Extensions can also extend the class itself. These methods should be placed in the +ClassMethods+ module within the class to extend, i.e. +Extensions::Awesome::ActiveRecord::Base::ClassMethods+.


28
29
30
31
32
# File 'lib/extensions.rb', line 28

def load(module_)
  module_extensions(module_).each do |path|
    load_extension_file(module_, path)
  end
end

.load_allvoid

This method returns an undefined value.

Loads all extensions defined in this directory.


9
10
11
12
13
14
# File 'lib/extensions.rb', line 9

def load_all
  Dir[EXTENSIONS_PATH + '/*.rb'].each do |ext|
    require ext
    load(const_get(module_name(File.basename(ext, '.*'))))
  end
end