Class: Conflict::DataBase
- Inherits:
-
Object
- Object
- Conflict::DataBase
- Defined in:
- lib/conflict/core.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #find_conflicts(client, events) ⇒ Object
-
#initialize ⇒ DataBase
constructor
A new instance of DataBase.
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ DataBase
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
#clear ⇒ Object
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 |
#size ⇒ Object
147 148 149 |
# File 'lib/conflict/core.rb', line 147 def size @db.size end |
#to_a ⇒ Object
155 156 157 |
# File 'lib/conflict/core.rb', line 155 def to_a @db.clone # don't return the real implementation end |