Sha256: 119b9cb092021f2d363f60c63ff41490e334f764ed6e16d86adea90934341d31

Contents?: true

Size: 925 Bytes

Versions: 4

Compression:

Stored size: 925 Bytes

Contents

module Relax
  class Service
    def initialize(values={}, options={})
      @values = values
      @options = options
    end

    def authenticate(*args)
      @options[:credentials] = args
      self
    end

    def proxy(url)
      @options[:proxy] = url
      self
    end

    def include_blank_values(value)
      @options[:include_blank_values] = value
      self
    end

    class << self
      include Contextable

      def endpoint(url, options={}, &block)
        Endpoint.new(self, url, options, &block)
      end

      def register_action(action) # :nodoc:
        @actions ||= {}

        unless @actions[action.name]
          @actions[action.name] = action.name

          define_method(action.name) do |*args|
            action.execute(@values, @options, *args)
          end
        else
          raise ArgumentError.new("Duplicate action '#{action.name}'.") 
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
tylerhunt-relax-0.1.2 lib/relax/service.rb
tylerhunt-relax-0.1.3 lib/relax/service.rb
relax-0.1.3 lib/relax/service.rb
relax-0.1.2 lib/relax/service.rb