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.0.1"
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}" define_method(:initialize) do |*args, &block| instance_variable_set(ivar, args.first) @__proxy_args = args[1..args.size] || [] end define_method(:__proxy_target__) do instance_variable_get(ivar) end define_method(:__proxy_kind__) do [:kind] || __proxy_target__.class 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 |