Class: HelixSync::ChangeService
- Inherits:
-
Object
- Object
- HelixSync::ChangeService
- Defined in:
- lib/helix_sync/change_service.rb
Overview
Front end to managing changelist-related resources.
This doesn't actually provide implementations, just hooks for other services.
Constant Summary
- @@create_pending_change =
[]
- @@fetch_latest_change =
[]
- @@fetch_pending_change =
[]
- @@submit_pending_change =
[]
Instance Attribute Summary (collapse)
-
- (Object) env
Rack environment.
Class Method Summary (collapse)
-
+ (Object) create_pending_change
Callback list for creating a pending changelist.
-
+ (Object) fetch_latest_change
Callback list for finding the latest changelist for a project.
-
+ (Object) fetch_pending_change
Callback list for finding the pending changelist for a project.
-
+ (Object) submit_pending_change
Callback list for submitting a pending changelist for a project.
Instance Method Summary (collapse)
-
- (Object) create_pending_change(project_id)
Returns the new pending change for the user and project ID.
-
- (Object) find_latest_change(project_id)
Returns the change found by the first handler that supports the project, or nil.
-
- (Object) find_pending_change(project_id)
Returns the change found by the first handler that supports the project, or nil.
-
- (ChangeService) initialize(env: nil)
constructor
A new instance of ChangeService.
- - (Object) submit_pending_change(project_id)
Constructor Details
- (ChangeService) initialize(env: nil)
Returns a new instance of ChangeService
11 12 13 |
# File 'lib/helix_sync/change_service.rb', line 11 def initialize(env: nil) @env = env end |
Instance Attribute Details
- (Object) env
Rack environment
9 10 11 |
# File 'lib/helix_sync/change_service.rb', line 9 def env @env end |
Class Method Details
+ (Object) create_pending_change
Callback list for creating a pending changelist
Your handler should return the changelist if your implementation handled creating the changelist number.
Each callback you add should consume these parameters:
-
project
[String]: The encoded project ID -
env
[Hash]: Current Rack environment
Example:
HelixSync::ChangeService.create_pending_change << lambda do |project, env|
create_change(project, env) if i_support?(project)
end
101 102 103 |
# File 'lib/helix_sync/change_service.rb', line 101 def self.create_pending_change @@create_pending_change end |
+ (Object) fetch_latest_change
Callback list for finding the latest changelist for a project.
Your handler should return the changelist if your implementation supports this particular project.
Each callback you add should consume these parameters:
-
project
[String]: The encoded project ID -
env
[Hash]: Current Rack environment
Example:
HelixSync::ChangeService.fetch_change << lambda do |project, env|
fetch_change(project, env) if i_support?(project)
end
36 37 38 |
# File 'lib/helix_sync/change_service.rb', line 36 def self.fetch_latest_change @@fetch_latest_change end |
+ (Object) fetch_pending_change
Callback list for finding the pending changelist for a project.
Your handler should return the changelist if your implementation supports this particular project.
Each callback you add should consume these parameters:
-
project
[String]: The encoded project ID -
env
[Hash]: Current Rack environment
Example:
HelixSync::ChangeService.fetch_change << lambda do |project, env|
fetch_change(project, env) if i_support?(project)
end
68 69 70 |
# File 'lib/helix_sync/change_service.rb', line 68 def self.fetch_pending_change @@fetch_pending_change end |
+ (Object) submit_pending_change
Callback list for submitting a pending changelist for a project
Your handler should return the changelist if your implementation handled creating the changelist number.
Each callback you add should consume these parameters:
-
project
[String]: The encoded project ID -
env
[Hash]: Current Rack environment
Example:
HelixSync::ChangeService.submit_pending_change << lambda do |project, changelist, env|
create_change(project, changelist, env) if i_support?(project)
end
133 134 135 |
# File 'lib/helix_sync/change_service.rb', line 133 def self.submit_pending_change @@submit_pending_change end |
Instance Method Details
- (Object) create_pending_change(project_id)
Returns the new pending change for the user and project ID
106 107 108 109 110 111 112 113 114 |
# File 'lib/helix_sync/change_service.rb', line 106 def create_pending_change(project_id) change_num = nil @@create_pending_change.find do |handler| c = handler.call(project_id, env) change_num = c if c c end change_num end |
- (Object) find_latest_change(project_id)
Returns the change found by the first handler that supports the project, or nil
42 43 44 45 46 47 48 49 50 |
# File 'lib/helix_sync/change_service.rb', line 42 def find_latest_change(project_id) change_num = nil @@fetch_latest_change.find do |handler| c = handler.call(project_id, env) change_num = c if c c end change_num end |
- (Object) find_pending_change(project_id)
Returns the change found by the first handler that supports the project, or nil
74 75 76 77 78 79 80 81 82 |
# File 'lib/helix_sync/change_service.rb', line 74 def find_pending_change(project_id) change_num = nil @@fetch_pending_change.find do |handler| c = handler.call(project_id, env) change_num = c if c c end change_num end |
- (Object) submit_pending_change(project_id)
137 138 139 140 141 |
# File 'lib/helix_sync/change_service.rb', line 137 def submit_pending_change(project_id) @@submit_pending_change.find do |handler| handler.call(project_id, env) end end |