Module: UniqueArray
- Defined in:
- lib/quickbooks/structure.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new ⇒ Object
234 235 236 |
# File 'lib/quickbooks/structure.rb', line 234 def self.new [].keep_unique! end |
.prepare_for_overwrites!(ary) ⇒ Object
224 225 226 227 228 229 230 231 232 233 |
# File 'lib/quickbooks/structure.rb', line 224 def self.prepare_for_overwrites!(ary) class << ary alias :push_without_unique :push alias :unshift_without_unique :unshift alias :append_without_unique :<< # This makes sure whatever kind of array (regular, slashed_structure, etc) it is, # keep_unique! will keep it unique at the type it was when it was told to stay unique. alias :_snapshot_include? :include? end end |
Instance Method Details
#<<(*args) ⇒ Object
248 249 250 251 252 |
# File 'lib/quickbooks/structure.rb', line 248 def <<(*args) args.each do |arg| append_without_unique(arg) unless _snapshot_include?(arg) end end |
#push(*args) ⇒ Object
238 239 240 241 242 |
# File 'lib/quickbooks/structure.rb', line 238 def push(*args) args.each do |arg| push_without_unique(arg) unless _snapshot_include?(arg) end end |
#unshift(*args) ⇒ Object
243 244 245 246 247 |
# File 'lib/quickbooks/structure.rb', line 243 def unshift(*args) args.each do |arg| unshift_without_unique(arg) unless _snapshot_include?(arg) end end |