-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for the auto_cores smart attribute to be used in the project manager.
- Loading branch information
1 parent
b8b9674
commit 16eefb0
Showing
7 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
apps/dashboard/app/lib/smart_attributes/attributes/auto_cores.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
module SmartAttributes | ||
class AttributeFactory | ||
# Build this attribute object. No options are used as this Attribute | ||
# is meant to be dynamically generated | ||
# @param opts [Hash] attribute's options | ||
# @return [Attributes::AutoGroups] the attribute object | ||
def self.build_auto_cores(opts = {}) | ||
Attributes::AutoCores.new('auto_cores', opts) | ||
end | ||
end | ||
|
||
module Attributes | ||
class AutoCores < Attribute | ||
def opts | ||
@opts.reverse_merge(min: 1, step: 1) | ||
end | ||
|
||
def widget | ||
'number_field' | ||
end | ||
|
||
def value | ||
(opts[:value] || '1').to_s | ||
end | ||
|
||
def label(*) | ||
(opts[:label] || 'Cores').to_s | ||
end | ||
|
||
# Submission hash describing how to submit this attribute | ||
# @return [Hash] submission hash | ||
def submit(*) | ||
cores = value.blank? ? 1 : value.to_i | ||
{ script: { cores: cores } } | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters