Module: ApexCharts::Prefixer

Included in:
Helper
Defined in:
lib/apexcharts/prefixer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(helper) ⇒ Object



3
4
5
# File 'lib/apexcharts/prefixer.rb', line 3

def self.extended(helper)
  @@helper = helper
end

Instance Method Details

#with_prefix(&block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/apexcharts/prefixer.rb', line 7

def with_prefix(&block)
  @@prefixed = Module.new(&block)

  unless [nil, ''].include? ApexCharts.helper_prefix
    (@@prefixed.instance_methods - @@helper.instance_methods).each do |method|
      @@prefixed.send(:alias_method, "#{ApexCharts.helper_prefix}#{method}", method)
      @@prefixed.send(:remove_method, method)
    end
  end
  @@helper.send(:include, @@prefixed)
end