Class: Unitylock::Server::Service
- Inherits:
-
Object
- Object
- Unitylock::Server::Service
- Defined in:
- lib/unitylock/server/service.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
- #deletes(*files) ⇒ Object
-
#initialize(model) ⇒ Service
constructor
A new instance of Service.
- #lock(file:, user:) ⇒ Object
- #search ⇒ Object
- #search_by_files(*files) ⇒ Object
- #touches(*files) ⇒ Object
- #unlock(file:, user:) ⇒ Object
Constructor Details
#initialize(model) ⇒ Service
Returns a new instance of Service.
7 8 9 |
# File 'lib/unitylock/server/service.rb', line 7 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
5 6 7 |
# File 'lib/unitylock/server/service.rb', line 5 def model @model end |
Instance Method Details
#deletes(*files) ⇒ Object
27 28 29 30 31 |
# File 'lib/unitylock/server/service.rb', line 27 def deletes(*files) files.each do |file| @model.delete(file: file) end end |
#lock(file:, user:) ⇒ Object
33 34 35 |
# File 'lib/unitylock/server/service.rb', line 33 def lock(file:,user:) @model.lock(file: file, user: user) end |
#search ⇒ Object
11 12 13 |
# File 'lib/unitylock/server/service.rb', line 11 def search @model.search.collect {|it| it.to_hash} end |
#search_by_files(*files) ⇒ Object
15 16 17 18 19 |
# File 'lib/unitylock/server/service.rb', line 15 def search_by_files(*files) @model.search .select {|it| files.include? it.file } .collect {|it| it.to_hash } end |
#touches(*files) ⇒ Object
21 22 23 24 25 |
# File 'lib/unitylock/server/service.rb', line 21 def touches(*files) files.each do |file| @model.create_or_update(file: file) end end |
#unlock(file:, user:) ⇒ Object
37 38 39 |
# File 'lib/unitylock/server/service.rb', line 37 def unlock(file:,user:) @model.unlock(file: file, user: user) end |