Class: BladeRunner::Model

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/blade_runner/model.rb

Direct Known Subclasses

Console::Tab, Session

Class Method Summary collapse

Class Method Details

.allObject



23
24
25
# File 'lib/blade_runner/model.rb', line 23

def all
  models.values
end

.create(attributes) ⇒ Object



9
10
11
12
13
# File 'lib/blade_runner/model.rb', line 9

def create(attributes)
  attributes[:id] ||= SecureRandom.hex(4)
  model = new(attributes)
  models[model.id] = model
end

.find(id) ⇒ Object



15
16
17
# File 'lib/blade_runner/model.rb', line 15

def find(id)
  models[id]
end

.modelsObject



5
6
7
# File 'lib/blade_runner/model.rb', line 5

def models
  @models ||= {}
end

.remove(id) ⇒ Object



19
20
21
# File 'lib/blade_runner/model.rb', line 19

def remove(id)
  models.delete(id)
end

.sizeObject



27
28
29
# File 'lib/blade_runner/model.rb', line 27

def size
  models.size
end