Module: ActivePresenter::Proxy

Defined in:
lib/proxy.rb

Class Method Summary collapse

Class Method Details

.new(options = {}, is_a_list = []) {|proxy| ... } ⇒ Object

Yields:

  • (proxy)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/proxy.rb', line 5

def self.new(options = {}, is_a_list = [])
  # this make each instance uniqiue. that measns that methods will only get defined for that instance of the proxy only.
  # the additional 'Ap' prefix is because String.randomize can sometimes start with a number which isn't valid for the first
  # character of a ruby class name.
  klass_name = "ActivePresenter::Proxy::Ap#{String.randomize.downcase}"
  eval %{
    class #{klass_name}
      include ActivePresenter::ProxyMethods
    end
  }
  proxy = klass_name.constantize.new(options, is_a_list)
  yield proxy if block_given?
  proxy
end