Sha256: 73a91f9690616c35273cfb7444b0e18e12af1b647ddf5ec3e19aa241835acb85

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

module Mobility
=begin

Abstract Module subclass with methods to define plugins and defaults.
Works with {Mobility::Plugin}. (Subclassed by {Mobility::Translations}.)

=end
  class Pluggable < Module
    class << self
      def plugin(name, *args)
        Plugin.configure(self, defaults) { __send__ name, *args }
      end

      def plugins(&block)
        Plugin.configure(self, defaults, &block)
      end

      def defaults
        @defaults ||= {}
      end

      def inherited(klass)
        super
        klass.defaults.merge!(defaults)
      end
    end

    def initialize(*, **options)
      @options = self.class.defaults.merge(options)
    end

    attr_reader :options
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mobility-1.0.0.alpha lib/mobility/pluggable.rb