Sha256: 543f76cd798f810affe052bdbe119c892ec09af8d2801fec5ee3dc6717210b3e

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

module Cistern::Request
  def self.service_request(service, klass, name)
    unless klass.name
      raise 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

2 entries across 2 versions & 1 rubygems

Version Path
cistern-2.2.3 lib/cistern/request.rb
cistern-2.2.1 lib/cistern/request.rb