Class: BladeRunner::Model
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- BladeRunner::Model
- Defined in:
- lib/blade_runner/model.rb
Direct Known Subclasses
Class Method Summary collapse
- .all ⇒ Object
- .create(attributes) ⇒ Object
- .find(id) ⇒ Object
- .models ⇒ Object
- .remove(id) ⇒ Object
- .size ⇒ Object
Class Method Details
.all ⇒ Object
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 |
.models ⇒ Object
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 |
.size ⇒ Object
27 28 29 |
# File 'lib/blade_runner/model.rb', line 27 def size models.size end |