Class: FeatureMap::CodeFeatures::Feature
- Inherits:
-
Object
- Object
- FeatureMap::CodeFeatures::Feature
- Defined in:
- lib/feature_map/code_features.rb
Constant Summary collapse
- LABEL_PREFIX =
'Feature '
- LABEL_LIMIT =
50
Instance Attribute Summary collapse
-
#config_yml ⇒ Object
readonly
Returns the value of attribute config_yml.
-
#raw_hash ⇒ Object
readonly
Returns the value of attribute raw_hash.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(config_yml:, raw_hash:) ⇒ Feature
constructor
A new instance of Feature.
- #label ⇒ Object
- #name ⇒ Object
- #to_tag ⇒ Object
Constructor Details
#initialize(config_yml:, raw_hash:) ⇒ Feature
Returns a new instance of Feature.
98 99 100 101 |
# File 'lib/feature_map/code_features.rb', line 98 def initialize(config_yml:, raw_hash:) @config_yml = config_yml @raw_hash = raw_hash end |
Instance Attribute Details
#config_yml ⇒ Object (readonly)
Returns the value of attribute config_yml.
96 97 98 |
# File 'lib/feature_map/code_features.rb', line 96 def config_yml @config_yml end |
#raw_hash ⇒ Object (readonly)
Returns the value of attribute raw_hash.
95 96 97 |
# File 'lib/feature_map/code_features.rb', line 95 def raw_hash @raw_hash end |
Class Method Details
.from_hash(raw_hash) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/feature_map/code_features.rb', line 88 def self.from_hash(raw_hash) new( config_yml: nil, raw_hash: raw_hash ) end |
.from_yml(config_yml) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/feature_map/code_features.rb', line 79 def self.from_yml(config_yml) hash = YAML.load_file(config_yml) new( config_yml: config_yml, raw_hash: hash ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
118 119 120 121 122 123 124 |
# File 'lib/feature_map/code_features.rb', line 118 def ==(other) if other.is_a?(CodeFeatures::Feature) name == other.name else false end end |
#hash ⇒ Object
128 129 130 |
# File 'lib/feature_map/code_features.rb', line 128 def hash name.hash end |
#label ⇒ Object
107 108 109 110 111 112 |
# File 'lib/feature_map/code_features.rb', line 107 def label # NOTE: Certain uses of feature labels have character # limits. This allows us to stay comfortably within # most without overly complex configuration. "#{LABEL_PREFIX}#{name}"[0...LABEL_LIMIT] end |
#name ⇒ Object
103 104 105 |
# File 'lib/feature_map/code_features.rb', line 103 def name Plugins::Identity.for(self).identity.name end |
#to_tag ⇒ Object
114 115 116 |
# File 'lib/feature_map/code_features.rb', line 114 def to_tag CodeFeatures.tag_value_for(name) end |