Sha256: ff5eb2bc6864d69bb723b745466ee4a139d7f0848469759734dce799d87cf675

Contents?: true

Size: 818 Bytes

Versions: 114

Compression:

Stored size: 818 Bytes

Contents

module Braintree
  module BaseModule # :nodoc: all
    module Methods
      def return_object_or_raise(object_to_return)
        result = yield
        if result.success?
          result.send object_to_return
        else
          raise ValidationsFailed.new(result)
        end
      end

      def copy_instance_variables_from_object(object)
        object.instance_variables.each do |ivar|
          instance_variable_set ivar, object.instance_variable_get(ivar)
        end
      end

      def set_instance_variables_from_hash(hash)
        hash.each do |key, value|
          instance_variable_set "@#{key}", value
        end
      end

      def singleton_class
        class << self; self; end
      end
    end

    def self.included(klass)
      klass.extend Methods
    end
    include Methods
  end
end

Version data entries

114 entries across 114 versions & 1 rubygems

Version Path
braintree-2.100.0 lib/braintree/base_module.rb
braintree-2.99.0 lib/braintree/base_module.rb
braintree-2.98.0 lib/braintree/base_module.rb
braintree-2.97.0 lib/braintree/base_module.rb
braintree-2.96.0 lib/braintree/base_module.rb
braintree-2.95.0 lib/braintree/base_module.rb
braintree-2.94.0 lib/braintree/base_module.rb
braintree-2.93.0 lib/braintree/base_module.rb
braintree-2.92.0 lib/braintree/base_module.rb
braintree-2.91.0 lib/braintree/base_module.rb
braintree-2.90.0 lib/braintree/base_module.rb
braintree-2.89.0 lib/braintree/base_module.rb
braintree-2.88.0 lib/braintree/base_module.rb
braintree-2.87.0 lib/braintree/base_module.rb
braintree-2.86.0 lib/braintree/base_module.rb
braintree-2.85.0 lib/braintree/base_module.rb
braintree-2.84.0 lib/braintree/base_module.rb
braintree-2.83.0 lib/braintree/base_module.rb
braintree-2.82.0 lib/braintree/base_module.rb
braintree-2.81.0 lib/braintree/base_module.rb