Class: Hoodie::Proxy
Overview
Turns object into a proxy which will forward all method missing calls.
Defined Under Namespace
Modules: Methods
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Proxy
constructor
A new instance of Proxy.
Constructor Details
#initialize(name, options = {}) ⇒ Proxy
Returns a new instance of Proxy.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hoodie/proxy.rb', line 26 def initialize(name, = {}) attr_reader name ivar = "@#{name}" attr_reader :__proxy_kind__, :__proxy_args__ define_method(:initialize) do |proxy_target, *args, &block| instance_variable_set(ivar, proxy_target) @__proxy_kind__ = .fetch(:kind) { proxy_target.class } @__proxy_args__ = args end define_method(:__proxy_target__) do instance_variable_get(ivar) end include Methods end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/hoodie/proxy.rb', line 24 def name @name end |