Sha256: 5e117b8e9dff29a4456f7a78ecc8ea195b76898008e1d28aa956037840a667ed

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

module Restfulie::Common::Converter::Components
  # This is a Blank Slate class to support the renderization of the values block for Resource Representation Interfaces
  # 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|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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restfulie-0.8.0 lib/restfulie/common/converter/values.rb