Sha256: bc7ce2158f1c00dc93e7e344179dd3e766e0735da604f3bfd0a2ab8108c24ecb

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 Bytes

Contents

module BBLib
  # 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.
  module TypeInit

    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

    module ClassMethods
      def type
        to_s.split('::').last.method_case.to_sym
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bblib-2.0.5 lib/bblib/core/mixins/type_init.rb
bblib-2.0.4 lib/bblib/core/mixins/type_init.rb
bblib-2.0.3 lib/bblib/core/mixins/type_init.rb