Class: MaglevRecord::ClassSnapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/maglev_record/snapshot/class_snapshot.rb

Instance Method Summary collapse

Constructor Details

#initialize(cls) ⇒ ClassSnapshot

Returns a new instance of ClassSnapshot.



6
7
8
9
10
11
12
13
14
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 6

def initialize(cls)
  cls.redo_include_and_extend
  @snapshot_class = cls
  @attributes = cls.snapshot_attributes if cls.respond_to? :snapshot_attributes
  @files = cls.file_paths
  @exists = cls.has_definitions?
  @class_methods = cls.snapshot_class_methods
  @instance_methods = cls.snapshot_instance_methods
end

Instance Method Details

#<=>(other) ⇒ Object



27
28
29
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 27

def <=>(other)
  class_name <=> other.class_name
end

#==(other) ⇒ Object Also known as: eql?



20
21
22
23
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 20

def ==(other)
      self.snapshot_class == other.snapshot_class \
  and self.exists? == other.exists?
end

#attributesObject



46
47
48
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 46

def attributes
  Array.new(@attributes || []).sort.uniq
end

#changed_since?(older) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 40

def changed_since?(older)
  attributes != older.attributes or
    instance_methods != older.instance_methods or
    class_methods != older.class_methods
end

#changes_since(older) ⇒ Object



35
36
37
38
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 35

def changes_since(older)
  return nil unless changed_since?(older)
  ClassChange.new(older, self)
end

#class_methodsObject



54
55
56
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 54

def class_methods
  Array.new(@class_methods)
end

#class_nameObject



50
51
52
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 50

def class_name
  @snapshot_class.name
end

#exists?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 16

def exists?
  @exists
end

#instance_methodsObject



58
59
60
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 58

def instance_methods
  @instance_methods
end

#snapshot_classObject



31
32
33
# File 'lib/maglev_record/snapshot/class_snapshot.rb', line 31

def snapshot_class
  @snapshot_class
end