Sha256: 436561fae9880d9ebe4109eb37daa419570774778a234cead9cc9e136a4961b8

Contents?: true

Size: 812 Bytes

Versions: 9

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module RakeFactory
  module Namespaceable
    # rubocop:disable Metrics/MethodLength
    def self.prepended(base)
      super(base)
      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(application)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rake_factory-0.32.0.pre.5 lib/rake_factory/namespaceable.rb
rake_factory-0.32.0.pre.4 lib/rake_factory/namespaceable.rb
rake_factory-0.32.0.pre.3 lib/rake_factory/namespaceable.rb
rake_factory-0.32.0.pre.2 lib/rake_factory/namespaceable.rb
rake_factory-0.32.0.pre.1 lib/rake_factory/namespaceable.rb
rake_factory-0.31.0 lib/rake_factory/namespaceable.rb
rake_factory-0.30.0.pre.8 lib/rake_factory/namespaceable.rb
rake_factory-0.30.0.pre.7 lib/rake_factory/namespaceable.rb
rake_factory-0.30.0.pre.6 lib/rake_factory/namespaceable.rb