Sha256: c89cfd315ca3d2e88fc431b9a22170bdc6d3139db4b7de7e59302a8a16fb1edb
Contents?: true
Size: 944 Bytes
Versions: 4
Compression:
Stored size: 944 Bytes
Contents
module Rtml::InheritedInstanceVariables def copy_ivars_from(source) ivars = source.instance_variables ivars -= source.protected_instance_variables if source.respond_to?(:protected_instance_variables) ivars.each { |ivar| instance_variable_set(ivar, source.instance_variable_get(ivar)) } rescue # fail silently if they can't be copied end def initialize_with_inherited_instance_variables(*a, &b) initialize_without_inherited_instance_variables(*a, &b) %w(controller document parent).each do |method| copy_ivars_from(send(method)) if respond_to?(method) rescue nil end end def self.included(base) base.instance_eval do class_inheritable_array :protected_instance_variables read_inheritable_attribute(:protected_instance_variables) || write_inheritable_attribute(:protected_instance_variables, []) alias_method_chain :initialize, :inherited_instance_variables end end end
Version data entries
4 entries across 4 versions & 1 rubygems