Sha256: 5993e07826579d15802fb8952a7e3ac6502ac525e0ad24e5be6ac3ee9e0093c2

Contents?: true

Size: 653 Bytes

Versions: 37

Compression:

Stored size: 653 Bytes

Contents

module ApiClient
  module Mixins
    module Instantiation
      def self.extended(base)
        base.instance_eval do
          attr_accessor :original_scope
        end
      end

      def build_one(hash)
        instance = self.new self.namespace ? hash[namespace] : hash
        instance.original_scope = self.scope.clone_only_headers
        instance
      end

      def build_many(array)
        array.collect { |one| build_one(one) }
      end

      def build(result_or_array)
        if result_or_array.is_a?(Array)
          build_many result_or_array
        else
          build_one  result_or_array
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
api_client-0.6.0-java lib/api_client/mixins/instantiation.rb
api_client-0.6.0 lib/api_client/mixins/instantiation.rb
api_client-0.5.26-java lib/api_client/mixins/instantiation.rb
api_client-0.5.26 lib/api_client/mixins/instantiation.rb
api_client-0.5.25-java lib/api_client/mixins/instantiation.rb
api_client-0.5.25 lib/api_client/mixins/instantiation.rb
api_client-0.5.24 lib/api_client/mixins/instantiation.rb
api_client-0.5.22 lib/api_client/mixins/instantiation.rb
api_client-0.5.21 lib/api_client/mixins/instantiation.rb
api_client-0.5.20 lib/api_client/mixins/instantiation.rb
api_client-0.5.19 lib/api_client/mixins/instantiation.rb
api_client-0.5.18 lib/api_client/mixins/instantiation.rb
api_client-0.5.17 lib/api_client/mixins/instantiation.rb
api_client-0.5.16 lib/api_client/mixins/instantiation.rb
api_client-0.5.15 lib/api_client/mixins/instantiation.rb
api_client-0.5.14 lib/api_client/mixins/instantiation.rb
api_client-0.5.13 lib/api_client/mixins/instantiation.rb
api_client-0.5.12 lib/api_client/mixins/instantiation.rb
api_client-0.5.11 lib/api_client/mixins/instantiation.rb
api_client-0.5.9 lib/api_client/mixins/instantiation.rb