Sha256: da085da1b734fb12a3841e22b654034a09bcebcc5ccfb121115b8388594ce03d

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module Cistern::Request
  def self.service_request(service, klass, name)
    unless klass.name
      fail ArgumentError, "can't turn anonymous class into a Cistern request"
    end

    service::Mock.module_eval <<-EOS, __FILE__, __LINE__
      def #{name}(*args)
        #{klass}.new(self)._mock(*args)
      end
    EOS

    service::Real.module_eval <<-EOS, __FILE__, __LINE__
      def #{name}(*args)
        #{klass}.new(self)._real(*args)
      end
    EOS
  end

  attr_reader :service

  def initialize(service)
    @service = service
  end

  module ClassMethods
    def service_method(name = nil)
      @_service_method ||= name
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cistern-2.2.7 lib/cistern/request.rb
cistern-2.2.6 lib/cistern/request.rb
cistern-2.2.5 lib/cistern/request.rb
cistern-2.2.4 lib/cistern/request.rb