Class: FeatureMap::CodeFeatures::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_map/code_features.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_yml:, raw_hash:) ⇒ Feature

Returns a new instance of Feature.



95
96
97
98
# File 'lib/feature_map/code_features.rb', line 95

def initialize(config_yml:, raw_hash:)
  @config_yml = config_yml
  @raw_hash = raw_hash
end

Instance Attribute Details

#config_ymlObject (readonly)

Returns the value of attribute config_yml.



93
94
95
# File 'lib/feature_map/code_features.rb', line 93

def config_yml
  @config_yml
end

#raw_hashObject (readonly)

Returns the value of attribute raw_hash.



92
93
94
# File 'lib/feature_map/code_features.rb', line 92

def raw_hash
  @raw_hash
end

Class Method Details

.from_hash(raw_hash) ⇒ Object



85
86
87
88
89
90
# File 'lib/feature_map/code_features.rb', line 85

def self.from_hash(raw_hash)
  new(
    config_yml: nil,
    raw_hash: raw_hash
  )
end

.from_yml(config_yml) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/feature_map/code_features.rb', line 76

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?



108
109
110
111
112
113
114
# File 'lib/feature_map/code_features.rb', line 108

def ==(other)
  if other.is_a?(CodeFeatures::Feature)
    name == other.name
  else
    false
  end
end

#hashObject



118
119
120
# File 'lib/feature_map/code_features.rb', line 118

def hash
  name.hash
end

#nameObject



100
101
102
# File 'lib/feature_map/code_features.rb', line 100

def name
  Plugins::Identity.for(self).identity.name
end

#to_tagObject



104
105
106
# File 'lib/feature_map/code_features.rb', line 104

def to_tag
  CodeFeatures.tag_value_for(name)
end