Module: BBLib::TypeInit

Included in:
OptsParser::Option
Defined in:
lib/bblib/core/mixins/type_init.rb

Overview

Requires Simple init to be loaded first. This sets up a very basic init foundation by adding a method called type and setting the init foundation method to it.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bblib/core/mixins/type_init.rb', line 7

def self.included(base)
  base.extend(ClassMethods)
  base.send(:bridge_method, :type)
  base.send(:serialize_method, :type, always: true)
  base.send(:setup_init_foundation, :type) do |a, b|
    if a && b
      case
      when a.is_a?(Array)
        a.include?(b)
      else
        a.to_s.to_sym == b.to_s.to_sym
      end
    else
      false
    end
  end
end