class Capsula::Wrapper

Attributes

item[RW]
store[R]

Objects-wrapper which is giving to objects ability to encapsulate other objects

Public Class Methods

new(_object_) click to toggle source
# File lib/capsula/wrapper.rb, line 11
def initialize _object_
  @item = _object_
  @store = {}
end

Public Instance Methods

[]=(key, val) click to toggle source

w=Capsula::Wrapper.new(1)

> 1

w = 2

> 2

w

> 1

w.a

> 2

# File lib/capsula/wrapper.rb, line 24
def []= key, val
  @store[key] = val
end
inspect() click to toggle source
# File lib/capsula/wrapper.rb, line 28
def inspect
  @item.inspect
end
method_missing(method, *args, &block) click to toggle source
# File lib/capsula/wrapper.rb, line 48
def method_missing(method, *args, &block)
  if store.has_key?(method)
    store[method]
  else
    @item.send(method, *args, &block)
  end
end
respond_to?(name, is_lookup_private = false) click to toggle source
# File lib/capsula/wrapper.rb, line 32
def respond_to? name, is_lookup_private = false
  self.store.include?(name) || @item.respond_to?(name, is_lookup_private)
end
try(*a, &b) click to toggle source
# File lib/capsula/wrapper.rb, line 43
def try *a, &b
  @item.try(*a, &b)
end