Module: Prototype::Prototypical::InstanceMethods

Defined in:
lib/alib-0.5.1/prototype.rb,
lib/alib-0.5.1/prototype-0.3.0.rb

Instance Method Summary collapse

Instance Method Details

#__prototype_init__(c = self.class) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/alib-0.5.1/prototype.rb', line 122

def __prototype_init__ c = self.class
  c.__prototype_table__.each do |ivar, value|
    #defined = instance_eval "defined? #{ ivar }"
    #unless defined
      instance_variable_set ivar, value
    #end

    a = ivar[%r/\w+/]
    defined = respond_to? a 
    unless defined
      self.class.module_eval{ attribute a }
    end
  end
end

#clone(*a, &b) ⇒ Object



147
148
149
150
151
152
153
154
# File 'lib/alib-0.5.1/prototype.rb', line 147

def clone *a, &b
  obj = prototype(self.class, *a, &b)
  instance_variables.each do |ivar|
    value = instance_variable_get ivar
    obj.instance_variable_set ivar, value
  end
  obj
end

#extend(*a, &b) ⇒ Object



137
138
139
140
141
142
143
144
145
# File 'lib/alib-0.5.1/prototype.rb', line 137

def extend *a, &b
  unless a.empty?
    super
  else
    self.class.__prototype_prototype__ &b
    __prototype_init__
    self
  end
end

#initialize(*a, &b) ⇒ Object



117
118
119
120
# File 'lib/alib-0.5.1/prototype.rb', line 117

def initialize *a, &b
  __prototype_init__
  super
end