Module: Gamefic::Serialize
- Included in:
- Element, Plot, Gamefic::Scene::Base, Gamefic::Scene::Base, Subplot
- Defined in:
- lib/gamefic/serialize.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.instances ⇒ Object
35 36 37 38 39 40 |
# File 'lib/gamefic/serialize.rb', line 35 def self.instances GC.start result = [] ObjectSpace.each_object(Gamefic::Serialize) { |obj| result.push obj } result end |
.string_to_constant(string) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/gamefic/serialize.rb', line 44 def self.string_to_constant string space = Object string.split('::').each do |part| space = space.const_get(part) end space end |
Instance Method Details
#serialized_class(index) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/gamefic/serialize.rb', line 27 def serialized_class index if index.include?(self.class) "#<ELE_#{index.index(self.class)}>" else self.class.to_s end end |
#to_serial(index = []) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gamefic/serialize.rb', line 5 def to_serial(index = []) if index.include?(self) { 'instance' => "#<ELE_#{index.index(self)}>", 'ivars' => {} } else if self.class == Class && self.name { 'class' => 'Class', 'name' => name } else index.push self if self.is_a?(Gamefic::Serialize) { 'class' => serialized_class(index), 'ivars' => serialize_instance_variables(index) } end end end |