Sha256: 66b9160d2b43b64ddb2026b81a2c642dc3d0bb7a9a36b636ecc133b786012037
Contents?: true
Size: 804 Bytes
Versions: 11
Compression:
Stored size: 804 Bytes
Contents
require 'rest-core/client' require 'rest-core/wrapper' class RestCore::Builder include RestCore include Wrapper class << self attr_writer :default_app end def self.default_app @default_app ||= RestClient end def self.client *attrs, &block new(&block).to_client(*attrs) end def to_client *attrs fields = members + attrs struct = if fields.empty? Struct.new(nil) else Struct.new(*fields) end client = Class.new(struct) client.const_set('Struct', struct) client.send(:include, Client) class << client; attr_reader :builder; end client.instance_variable_set(:@builder, self) client end def initialize &block @middles ||= [] instance_eval(&block) if block_given? end end
Version data entries
11 entries across 11 versions & 1 rubygems