class Prependers::Prepender

Constants

NAMESPACE_DEPRECATION

Attributes

options[R]

Public Class Methods

[](options = {}) click to toggle source
# File lib/prependers/prepender.rb, line 5
def self.[](options = {})
  new(options)
end
new(options_or_namespace = {}) click to toggle source
# File lib/prependers/prepender.rb, line 15
def initialize(options_or_namespace = {})
  if options_or_namespace.is_a?(Module)
    warn NAMESPACE_DEPRECATION % { namespace: options_or_namespace }
    options_or_namespace = { namespace: options_or_namespace }
  end

  @options = options_or_namespace
end

Public Instance Methods

included(base) click to toggle source
# File lib/prependers/prepender.rb, line 24
def included(base)
  if options.key?(:namespace)
    base.include Prependers::Annotate::Namespace.new(options[:namespace])
  end

  if options.key?(:verify)
    base.include Prependers::Annotate::Verify.new(options[:verify])
  end

  prependable = Prependers.prependable_for(base)

  prependable.prepend(base)

  if base.const_defined?('ClassMethods')
    prependable.singleton_class.prepend(base.const_get('ClassMethods'))
  end
end