Class: ConventionalCommits::Configuration::TypeConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/models/type_configuration.rb

Overview

Configuration for branch name policies

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(o = {}) ⇒ TypeConfiguration

Returns a new instance of TypeConfiguration.



9
10
11
# File 'lib/models/type_configuration.rb', line 9

def initialize(o = {})
  @options = o
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/models/type_configuration.rb', line 7

def options
  @options
end

Instance Method Details

#all_typesObject



26
27
28
# File 'lib/models/type_configuration.rb', line 26

def all_types
  options.keys + options.values.flat_map { |e| e }
end

#is_allowed(type) ⇒ Object



13
14
15
# File 'lib/models/type_configuration.rb', line 13

def is_allowed(type)
  all_types.include?(type)
end

#main_type(_type) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/models/type_configuration.rb', line 17

def main_type(_type)
  match = ""

  options.each do |key, array|
    match = key if array.include?(_type)
  end
  match
end