Class: CallbackArray

Inherits:
Array
  • Object
show all
Includes:
ActiveSupport::Callbacks
Defined in:
lib/data_frame/callback_array.rb

Overview

This overloads the tainting methods in array with callbacks. So, I can block all changes to an array, or broadcast to observers after a change, or limit the size of an array. It really just opens up the array to one more dimension: change. Before and after change, stack up any activity to block or enhance the experience. There are also callbacks on untaint. The tainting methods actually

Direct Known Subclasses

TransposableArray

Instance Method Summary collapse

Methods inherited from Array

#dimensions

Instance Method Details

#<<(value) ⇒ Object



49
50
51
# File 'lib/data_frame/callback_array.rb', line 49

def <<(value)
  wrap_call(:nontainting_append, value)
end

#[]=(index, value) ⇒ Object



44
45
46
# File 'lib/data_frame/callback_array.rb', line 44

def []=(index, value)
  wrap_call(:nontainting_assign, index, value)
end

#clearObject



148
149
150
# File 'lib/data_frame/callback_array.rb', line 148

def clear
  wrap_call(:nontainting_clear)
end

#collect!(&block) ⇒ Object



106
107
108
109
110
111
112
113
114
# File 'lib/data_frame/callback_array.rb', line 106

def collect!(&block)
  callback_result = run_callbacks(:before_taint)
  if callback_result
    result = nontainting_collect!(&block)
    self.orig_taint
    run_callbacks(:after_taint)
  end
  result
end

#compact!Object



117
118
119
# File 'lib/data_frame/callback_array.rb', line 117

def compact!
  wrap_call(:nontainting_compact!)
end

#delete(value) ⇒ Object



54
55
56
# File 'lib/data_frame/callback_array.rb', line 54

def delete(value)
  wrap_call(:nontainting_delete, value)
end

#flatten!Object



138
139
140
# File 'lib/data_frame/callback_array.rb', line 138

def flatten!
  wrap_call(:nontainting_flatten!)
end

#map!(&block) ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'lib/data_frame/callback_array.rb', line 79

def map!(&block)
  callback_result = run_callbacks(:before_taint)
  if callback_result
    result = nontainting_map!(&block)
    self.orig_taint
    run_callbacks(:after_taint)
  end
  result
end

#nontainting_appendObject



48
# File 'lib/data_frame/callback_array.rb', line 48

alias :nontainting_append :<<

#nontainting_assignObject



43
# File 'lib/data_frame/callback_array.rb', line 43

alias :nontainting_assign :[]=

#nontainting_clearObject



147
# File 'lib/data_frame/callback_array.rb', line 147

alias :nontainting_clear :clear

#nontainting_collect!Object



105
# File 'lib/data_frame/callback_array.rb', line 105

alias :nontainting_collect! :collect!

#nontainting_compact!Object



116
# File 'lib/data_frame/callback_array.rb', line 116

alias :nontainting_compact! :compact!

#nontainting_deleteObject



53
# File 'lib/data_frame/callback_array.rb', line 53

alias :nontainting_delete :delete

#nontainting_flatten!Object



137
# File 'lib/data_frame/callback_array.rb', line 137

alias :nontainting_flatten! :flatten!

#nontainting_map!Object



78
# File 'lib/data_frame/callback_array.rb', line 78

alias :nontainting_map! :map!

#nontainting_popObject



63
# File 'lib/data_frame/callback_array.rb', line 63

alias :nontainting_pop :pop

#nontainting_pushObject



58
# File 'lib/data_frame/callback_array.rb', line 58

alias :nontainting_push :push

#nontainting_reject!Object



121
# File 'lib/data_frame/callback_array.rb', line 121

alias :nontainting_reject! :reject!

#nontainting_reverse!Object



100
# File 'lib/data_frame/callback_array.rb', line 100

alias :nontainting_reverse! :reverse!

#nontainting_shiftObject



68
# File 'lib/data_frame/callback_array.rb', line 68

alias :nontainting_shift :shift

#nontainting_slice!Object



132
# File 'lib/data_frame/callback_array.rb', line 132

alias :nontainting_slice! :slice!

#nontainting_sort!Object



89
# File 'lib/data_frame/callback_array.rb', line 89

alias :nontainting_sort! :sort!

#nontainting_uniq!Object



142
# File 'lib/data_frame/callback_array.rb', line 142

alias :nontainting_uniq! :uniq!

#nontainting_unshiftObject



73
# File 'lib/data_frame/callback_array.rb', line 73

alias :nontainting_unshift :unshift

#orig_taintObject

Need the original taint for all tainting methods



21
# File 'lib/data_frame/callback_array.rb', line 21

alias :orig_taint :taint

#popObject



64
65
66
# File 'lib/data_frame/callback_array.rb', line 64

def pop
  wrap_call(:nontainting_pop)
end

#push(value) ⇒ Object



59
60
61
# File 'lib/data_frame/callback_array.rb', line 59

def push(value)
  wrap_call(:nontainting_push, value)
end

#reject!(&block) ⇒ Object



122
123
124
125
126
127
128
129
130
# File 'lib/data_frame/callback_array.rb', line 122

def reject!(&block)
  callback_result = run_callbacks(:before_taint)
  if callback_result
    result = nontainting_reject!(&block)
    self.orig_taint
    run_callbacks(:after_taint)
  end
  result
end

#reverse!Object



101
102
103
# File 'lib/data_frame/callback_array.rb', line 101

def reverse!
  wrap_call(:nontainting_reverse!)
end

#shiftObject



69
70
71
# File 'lib/data_frame/callback_array.rb', line 69

def shift
  wrap_call(:nontainting_shift)
end

#slice!(*args) ⇒ Object



133
134
135
# File 'lib/data_frame/callback_array.rb', line 133

def slice!(*args)
  wrap_call(:nontainting_slice!, *args)
end

#sort!(&block) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/data_frame/callback_array.rb', line 90

def sort!(&block)
  callback_result = run_callbacks(:before_taint)
  if callback_result
    result = nontainting_sort!(&block)
    self.orig_taint
    run_callbacks(:after_taint)
  end
  result
end

#taintObject



22
23
24
25
26
27
28
29
# File 'lib/data_frame/callback_array.rb', line 22

def taint
  callback_result = run_callbacks(:before_taint)
  if callback_result
    result = self.orig_taint
    run_callbacks(:after_taint)
  end
  result
end

#uniq!Object



143
144
145
# File 'lib/data_frame/callback_array.rb', line 143

def uniq!
  wrap_call(:nontainting_uniq!)
end

#unshift(value) ⇒ Object



74
75
76
# File 'lib/data_frame/callback_array.rb', line 74

def unshift(value)
  wrap_call(:nontainting_unshift, value)
end