Sha256: d0f1bff0cfa8d46dc9096a8be0e8aaf20f6ec839f5f9f43aead201ff9e88ff1f

Contents?: true

Size: 869 Bytes

Versions: 7

Compression:

Stored size: 869 Bytes

Contents

module Mattock
  module Configurable
    class ProxyValue
      def initialize(source, field)
        @source, @field = source, field
      end
      attr_reader :source, :field

      def inspect
        "#{self.class.name.split(':').last}: #{source.class.name}.#{field.inspect}"
      end
    end

    class ProxyDecorator
      def initialize(configurable)
        @configurable = configurable
      end

      def method_missing(name, *args, &block)
        unless block.nil? and args.empty?
          raise NoMethodError, "method `#{name}' not defined with arguments or block when proxied"
        end
        unless @configurable.respond_to?(name)
          raise NoMethodError, "cannot proxy `#{name}' - undefined on #{@configurable}"
        end
        return ProxyValue.new(@configurable, @configurable.class.field_metadata(name))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mattock-0.9.0 lib/mattock/configurable/proxy-value.rb
mattock-0.8.0 lib/mattock/configurable/proxy-value.rb
mattock-0.7.1 lib/mattock/configurable/proxy-value.rb
mattock-0.7.0 lib/mattock/configurable/proxy-value.rb
mattock-0.5.3 lib/mattock/configurable/proxy-value.rb
mattock-0.5.2 lib/mattock/configurable/proxy-value.rb
mattock-0.5.0 lib/mattock/configurable/proxy-value.rb