Sha256: 40c27cd3fed22e7f903ce744565f099e7181dc877cda71554c800e45f66df290
Contents?: true
Size: 753 Bytes
Versions: 2
Compression:
Stored size: 753 Bytes
Contents
require 'rest-core/client' require 'rest-core/wrapper' class RestCore::Builder include RestCore include Wrapper 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rest-core-1.0.3 | lib/rest-core/builder.rb |
rest-core-1.0.2 | lib/rest-core/builder.rb |