Sha256: 9f24adc161bc6abf7d12ee00143fd34dfbb664df5c16716a099e0cf71adb082f

Contents?: true

Size: 966 Bytes

Versions: 5

Compression:

Stored size: 966 Bytes

Contents

module Restfulie
  module Common
    module Converter
      # 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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
restfulie-1.0.0.beta1 lib/restfulie/common/converter/values.rb
restfulie-0.1.0.beta1 lib/restfulie/common/converter/values.rb
restfulie-0.9.3 lib/restfulie/common/converter/values.rb
restfulie-0.9.1 lib/restfulie/common/converter/values.rb
restfulie-0.8.1 lib/restfulie/common/converter/values.rb