Sha256: 77ff711e4732909ac72cc258c2e0dfb19292e2aa664f05cf1b090bd741a469ef
Contents?: true
Size: 670 Bytes
Versions: 1
Compression:
Stored size: 670 Bytes
Contents
module Structure module ClassMethods def double klass = Class.new(self) ( private_instance_methods(false) + protected_instance_methods(false) - [:initialize] ).each do |name| klass.send(:undef_method, name) end klass.module_eval do def initialize(data = {}) data.each { |key, value| instance_variable_set(:"@#{key}", value) } end attribute_names.each do |name| module_eval "def _#{name}; @#{name}; end" private "_#{name}" end module_eval(&Proc.new) if block_given? end klass end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
structure-1.0.0 | lib/structure/double.rb |