Class: Breeze::ChangeSet

Inherits:
Object
  • Object
show all
Defined in:
app/models/breeze/change_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChangeSet

Returns a new instance of ChangeSet.



10
11
12
# File 'app/models/breeze/change_set.rb', line 10

def initialize
  zero
end

Instance Attribute Details

#addsObject (readonly)

Returns the value of attribute adds.



8
9
10
# File 'app/models/breeze/change_set.rb', line 8

def adds
  @adds
end

#deletesObject (readonly)

Returns the value of attribute deletes.



8
9
10
# File 'app/models/breeze/change_set.rb', line 8

def deletes
  @deletes
end

#editsObject (readonly)

Returns the value of attribute edits.



8
9
10
# File 'app/models/breeze/change_set.rb', line 8

def edits
  @edits
end

#lastObject (readonly)

Returns the value of attribute last.



8
9
10
# File 'app/models/breeze/change_set.rb', line 8

def last
  @last
end

#last_editorObject (readonly)

Returns the value of attribute last_editor.



8
9
10
# File 'app/models/breeze/change_set.rb', line 8

def last_editor
  @last_editor
end

Class Method Details

.currentObject



5
6
7
# File 'app/models/breeze/change_set.rb', line 5

def self.current
  @@current ||= ChangeSet.new
end

Instance Method Details

#add(type, text, editor) ⇒ Object



27
28
29
30
# File 'app/models/breeze/change_set.rb', line 27

def add( type , text , editor)
  touch(editor)
  @adds << [typed(type) , text ]
end

#added(type) ⇒ Object



41
42
43
44
# File 'app/models/breeze/change_set.rb', line 41

def added( type )
  type = type.to_sym
  @adds.select { |a| a.first == type }
end

#delete(type, text, editor) ⇒ Object



36
37
38
39
# File 'app/models/breeze/change_set.rb', line 36

def delete( type , text, editor)
  touch(editor)
  @deletes << [typed(type) , text ]
end

#deleted(type) ⇒ Object



49
50
51
52
# File 'app/models/breeze/change_set.rb', line 49

def deleted( type )
  type = type.to_sym
  @deletes.select { |a| a.first == type }
end

#edit(type, text, editor) ⇒ Object



32
33
34
35
# File 'app/models/breeze/change_set.rb', line 32

def edit( type , text, editor)
  touch(editor)
  @edits << [typed(type) , text ]
end

#edited(type) ⇒ Object



45
46
47
48
# File 'app/models/breeze/change_set.rb', line 45

def edited( type )
  type = type.to_sym
  @edits.select { |a| a.first == type }
end

#touch(editor) ⇒ Object



22
23
24
25
# File 'app/models/breeze/change_set.rb', line 22

def touch(editor)
  @last = Time.now
  @last_editor = editor
end

#typed(class_name) ⇒ Object



54
55
56
# File 'app/models/breeze/change_set.rb', line 54

def typed(class_name)
  class_name.split("::").last.to_sym
end

#zeroObject



14
15
16
17
18
19
20
# File 'app/models/breeze/change_set.rb', line 14

def zero
  @adds = Set.new
  @edits = Set.new
  @deletes = Set.new
  @last = nil
  @last_editor = nil
end