Sha256: 343e606d02e4801fa39671ce085ee1acd235c6d2b89f16e6a4945a9cc6f558d4

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

module Burlap
  class Call
    attr_accessor :headers, :method, :arguments

    def initialize params={}
      params.each do |key, value|
        method = :"#{key}="
        send(method, value) if respond_to?(method)
      end

      validate_attributes
    end

    def headers
      @headers ||= {}
    end

    def arguments
      @arguments ||= []
    end

    def to_burlap
      # todo: handle headers
      contents = [Burlap::Node.new(:name => "method", :value => method).to_burlap]
      contents += arguments.map do |arg|
        arg.to_burlap
      end
      Burlap::Node.new(:name => "burlap:call", :value => contents.join("")).to_burlap
    end

  protected

    def validate_attributes
      raise(ArgumentError, "method is required") unless self.method
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
burlap-1.0.0 lib/burlap/call.rb