Sha256: 22f9c534ee4af167f75f5be4f4e375bf4a732cb46f5193fef45c49f9d3f6dcae

Contents?: true

Size: 379 Bytes

Versions: 15

Compression:

Stored size: 379 Bytes

Contents

require 'cli/kit'

module CLI
  module Kit
    module Autocall
      def autocall(const, &block)
        @autocalls ||= {}
        @autocalls[const] = block
      end

      def const_missing(const)
        block = begin
          @autocalls.fetch(const)
        rescue KeyError
          return super
        end
        const_set(const, block.call)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
cli-kit-4.0.0 lib/cli/kit/autocall.rb
shopify-cli-1.0.5 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-1.0.4 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-1.0.3 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-1.0.2 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-1.0.1 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-1.0.0 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-0.9.3 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-0.9.2 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-0.9.1 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
shopify-cli-0.9.0 vendor/deps/cli-kit/lib/cli/kit/autocall.rb
cli-kit-3.3.0 lib/cli/kit/autocall.rb
cli-kit-3.1.0 lib/cli/kit/autocall.rb
cli-kit-3.0.1 lib/cli/kit/autocall.rb
cli-kit-3.0.0 lib/cli/kit/autocall.rb