Class: FastlaneCore::Feature
- Inherits:
-
Object
- Object
- FastlaneCore::Feature
- Defined in:
- fastlane_core/lib/fastlane_core/feature/feature.rb
Class Attribute Summary collapse
-
.features ⇒ Object
readonly
Returns the value of attribute features.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#env_var ⇒ Object
readonly
Returns the value of attribute env_var.
Class Method Summary collapse
- .enabled?(env_var) ⇒ Boolean
- .register(env_var: nil, description: nil) ⇒ Object
- .register_class_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) ⇒ Object
- .register_instance_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(env_var: nil, description: nil) ⇒ Feature
constructor
A new instance of Feature.
Constructor Details
#initialize(env_var: nil, description: nil) ⇒ Feature
Returns a new instance of Feature.
45 46 47 48 49 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 45 def initialize(env_var: nil, description: nil) raise "Invalid Feature" if env_var.nil? || description.nil? @env_var = env_var @description = description end |
Class Attribute Details
.features ⇒ Object (readonly)
Returns the value of attribute features.
6 7 8 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 6 def features @features end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
44 45 46 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 44 def description @description end |
#env_var ⇒ Object (readonly)
Returns the value of attribute env_var.
44 45 46 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 44 def env_var @env_var end |
Class Method Details
.enabled?(env_var) ⇒ Boolean
13 14 15 16 17 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 13 def enabled?(env_var) feature = @features[env_var] return false if feature.nil? return FastlaneCore::Env.truthy?(feature.env_var) end |
.register(env_var: nil, description: nil) ⇒ Object
8 9 10 11 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 8 def register(env_var: nil, description: nil) feature = self.new(description: description, env_var: env_var) @features[feature.env_var] = feature end |
.register_class_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 19 def register_class_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) return if klass.nil? || symbol.nil? || disabled_symbol.nil? || enabled_symbol.nil? || env_var.nil? klass.define_singleton_method(symbol) do |*args| if Feature.enabled?(env_var) klass.send(enabled_symbol, *args) else klass.send(disabled_symbol, *args) end end end |
.register_instance_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'fastlane_core/lib/fastlane_core/feature/feature.rb', line 30 def register_instance_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) return if klass.nil? || symbol.nil? || disabled_symbol.nil? || enabled_symbol.nil? || env_var.nil? klass.send(:define_method, symbol.to_s) do |*args| if Feature.enabled?(env_var) send(enabled_symbol, *args) else send(disabled_symbol, *args) end end end |