Class: Charlatan
- Inherits:
-
Module
- Object
- Module
- Charlatan
- Defined in:
- lib/charlatan.rb,
lib/charlatan/version.rb
Overview
Charlatan turns your object into a proxy which will forward all method missing calls to object it’s wrapping
Defined Under Namespace
Modules: Methods
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Charlatan
constructor
A new instance of Charlatan.
Constructor Details
#initialize(name, options = {}) ⇒ Charlatan
Returns a new instance of Charlatan.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/charlatan.rb', line 21 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.
19 20 21 |
# File 'lib/charlatan.rb', line 19 def name @name end |