module ExtendIt::DslModule

Public Class Methods

extended(base) click to toggle source
# File lib/extend_it/dsl.rb, line 201
def self.extended(base)
  unless base.is_a?(Module)
    fail 'DslModule can be only extended by modules'
  end

  base.define_singleton_method :included do |superbase|
    if @included.is_a?(Array)
      @included.each { |i| superbase.instance_eval(&i) }
    end
    if @dsl.is_a?(Array) && superbase.respond_to?(:dsl)
      @dsl.each { |d| superbase.dsl(&d) }
    end
  end

  base.define_singleton_method :extended do |superbase|
    if @extended.is_a?(Array)
      @extended.each { |e| superbase.instance_eval(&e) }
    end
    if @dsl.is_a?(Array) && superbase.respond_to?(:dsl)
      @dsl.each { |d| superbase.dsl(&d) }
    end
  end
end
incuded(base) click to toggle source
# File lib/extend_it/dsl.rb, line 197
def self.incuded(base)
  fail 'DslModule can be only extended by other modules'
end

Public Instance Methods

dsl(&block) click to toggle source
# File lib/extend_it/dsl.rb, line 233
def dsl(&block)
  (@dsl ||= []) << block if block_given?
end
extended(&block) click to toggle source
# File lib/extend_it/dsl.rb, line 229
def extended(&block)
  (@extended ||= []) << block if block_given?
end
included(&block) click to toggle source
# File lib/extend_it/dsl.rb, line 225
def included(&block)
  (@included ||= []) << block if block_given?
end