Class: Conflict::DataBase

Inherits:
Object
  • Object
show all
Defined in:
lib/conflict/core.rb

Instance Method Summary collapse

Constructor Details

#initializeDataBase

Returns a new instance of DataBase.



123
124
125
# File 'lib/conflict/core.rb', line 123

def initialize
  @db = [] # yes, it is seriously just an array

end

Instance Method Details

#clearObject



151
152
153
# File 'lib/conflict/core.rb', line 151

def clear
  @db.clear
end

#find_conflicts(client, events) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/conflict/core.rb', line 127

def find_conflicts client, events
  
  validate_input client, events

  purge client
  
  conflicts = []
  
  if events.size > 0
    events.each do | event | # keep this until we get performance problems

      @db.each do | historic_event |
        conflicts << Conflict::new( event, historic_event) if event.resource.eql?(historic_event.resource)
      end
    end
    @db = @db | events 
  end
  
  conflicts
end

#sizeObject



147
148
149
# File 'lib/conflict/core.rb', line 147

def size
  @db.size
end

#to_aObject



155
156
157
# File 'lib/conflict/core.rb', line 155

def to_a
  @db.clone # don't return the real implementation

end