Sha256: 02b2638f150f4d61cd7998d9c6d550f276121eff1abdd3b0bb51867f1e61311b

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

module DocSmoosher
  class Request < ApiObject
    attr_accessor :call_type, :path, :fields, :response

    def initialize(params = {}, &block)
      # Defaults
      self.call_type = :get
      
      super(params)
    end


    def fields
      @fields ||= []
    end

    def field(params = {}, &block)
      if params.class == Field
        f = params
      else
        f = Field.new(params, &block)
      end
      fields << f unless fields.include?(f)
      p
    end

    def as_json(options={})
      super.merge(
        {
          :fields => fields.map(&:as_json),
          :parameters => parameters.map(&:as_json)
        }
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doc_smoosher-0.1.0 lib/doc_smoosher/request.rb