Sha256: 9d995b367e13f9e9c83d2dbc99aea140cdd58e4406b3a1fab7d5f3dcb855c3ca

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 Bytes

Contents

module Hypertemplate
  module Builder
  
    # This is a Blank Slate class to support the renderization of the values block of Builder DSLs
    # Every Media type should implement a Builder with a insert_value method that renders the values block to a specific format
    class Values
      attr_accessor :builder

      # BlankSlate
      instance_methods.each do |m|
        undef_method m unless m.to_s =~ /\[\]|method_missing|object_id|send|respond_to\?|^__/
      end

      def initialize(builder)
        @builder = builder
        @current_prefix = nil
      end

      def [](prefix)
        @current_prefix = prefix
        self
      end

      def method_missing(symbol, *args, &block)
        name = symbol.to_s
        prefix = @current_prefix
        @current_prefix = nil
        @builder.insert_value(name, prefix, *args, &block)
      end
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hypertemplate-1.2.2 lib/hypertemplate/builder/values.rb
hypertemplate-1.2.1 lib/hypertemplate/builder/values.rb
hypertemplate-1.2.0 lib/hypertemplate/builder/values.rb