Class: Skylight::Util::Component Private
- Defined in:
- lib/skylight/util/component.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- NAME_FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\A[a-zA-Z0-9_-]+\z/.freeze
- DEFAULT_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"web"- WORKER_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"worker"- DEFAULT_ENVIRONMENT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"production"
Instance Attribute Summary collapse
- #environment ⇒ Object private
- #name ⇒ Object private
Instance Method Summary collapse
-
#as_json ⇒ Object
private
keys here should match those from the main config.
-
#initialize(environment, name, force_worker: false) ⇒ Component
constructor
private
A new instance of Component.
- #to_encoded_s ⇒ Object private
- #to_s ⇒ Object private
- #web? ⇒ Boolean private
- #worker? ⇒ Boolean private
Constructor Details
#initialize(environment, name, force_worker: false) ⇒ Component
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Component.
15 16 17 18 19 20 21 22 23 |
# File 'lib/skylight/util/component.rb', line 15 def initialize(environment, name, force_worker: false) @environment = environment || DEFAULT_ENVIRONMENT @name = resolve_name(name, force_worker) raise ArgumentError, "environment can't be blank" if @environment.empty? validate_string!(@environment, "environment") validate_string!(@name, "name") end |
Instance Attribute Details
#environment ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/skylight/util/component.rb', line 8 def environment @environment end |
#name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/skylight/util/component.rb', line 8 def name @name end |
Instance Method Details
#as_json ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
keys here should match those from the main config
42 43 44 |
# File 'lib/skylight/util/component.rb', line 42 def as_json(*) { component: name, env: environment } end |
#to_encoded_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/skylight/util/component.rb', line 29 def to_encoded_s @to_encoded_s ||= URI.encode_www_form_component(to_s) end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/skylight/util/component.rb', line 25 def to_s "#{name}:#{environment}" end |
#web? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/skylight/util/component.rb', line 33 def web? name == DEFAULT_NAME end |
#worker? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/skylight/util/component.rb', line 37 def worker? !web? end |