Sha256: ac05c9fb80b46698dfb487975a25d39389eed0ef4459c7d8e3ce985e896d613b

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

module RakeFactory
  module Namespaceable
    # rubocop:disable Metrics/MethodLength
    def self.prepended(base)
      super
      base.class_eval do
        parameter(:namespace, transform: lambda { |name|
          name = name.to_s if name.is_a?(Symbol)
          name = name.to_str if name.respond_to?(:to_str)
          unless name.is_a?(String) || name.nil?
            raise ArgumentError,
                  'Expected a String or Symbol for a namespace name'
          end
          name
        })
      end
    end
    # rubocop:enable Metrics/MethodLength

    def around_define(application)
      if namespace
        application.in_namespace(namespace) do
          super(application)
        end
      else
        super
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rake_factory-0.34.0.pre.2 lib/rake_factory/namespaceable.rb
rake_factory-0.34.0.pre.1 lib/rake_factory/namespaceable.rb
rake_factory-0.33.0 lib/rake_factory/namespaceable.rb
rake_factory-0.32.0.pre.6 lib/rake_factory/namespaceable.rb