Class: Defmastership::DefTypeList

Inherits:
Object
  • Object
show all
Defined in:
lib/defmastership/def_type_list.rb

Overview

Handle the possible configurations of def_type

Instance Method Summary collapse

Constructor Details

#initialize(def_type_config) ⇒ DefTypeList

Returns a new instance of DefTypeList.

Parameters:

  • def_type_config (String, Array<String>)

    the definition’s type configuration



8
9
10
11
12
13
14
# File 'lib/defmastership/def_type_list.rb', line 8

def initialize(def_type_config)
  if ['', 'all'].include?(def_type_config)
    @allow_all = true
  else
    @allowed_types = Array(def_type_config)
  end
end

Instance Method Details

#include?(def_type) ⇒ Boolean

Returns true if the type is included in the DefTypeList instance.

Parameters:

  • def_type (String)

    the definition’s type to test

Returns:

  • (Boolean)

    true if the type is included in the DefTypeList instance



19
20
21
22
23
# File 'lib/defmastership/def_type_list.rb', line 19

def include?(def_type)
  return true if @allow_all

  @allowed_types.include?(def_type)
end