Sha256: 7ff7038005df45c5342d3c6418288173a7e772bf6cdf905c8878be4c3fdd2521

Contents?: true

Size: 685 Bytes

Versions: 6

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

module Snowpack
  module Console
    module Plugins
      class SliceReaders < Module
        def initialize(ctx)
          ctx.application.slices.each do |name, slice|
            define_method(name) do
              SliceDelegator.new(slice)
            end
          end
        end

        class SliceDelegator < SimpleDelegator
          def method_missing(name, *args, &block)
            if args.empty? && key?(name)
              self[name]
            else
              super
            end
          end

          private

          def respond_to_missing?(name)
            key?(name)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
snowpack-1.0.0.alpha7 lib/snowpack/console/plugins/slice_readers.rb
snowpack-1.0.0.alpha6 lib/snowpack/console/plugins/slice_readers.rb
snowpack-1.0.0.alpha5 lib/snowpack/console/plugins/slice_readers.rb
snowpack-1.0.0.alpha4 lib/snowpack/console/plugins/slice_readers.rb
snowpack-1.0.0.alpha3 lib/snowpack/console/plugins/slice_readers.rb
snowpack-1.0.0.alpha2 lib/snowpack/console/plugins/slice_readers.rb