Sha256: a9fc7429bc7efba0513a9f83315546728e23920e665ea96584b1a41d2512101e
Contents?: true
Size: 1011 Bytes
Versions: 1
Compression:
Stored size: 1011 Bytes
Contents
module Braintree # A SuccessfulResult will be returned from non-bang methods when # validations pass. It will provide access to the created resource. # For example, when creating a customer, SuccessfulResult will # respond to +customer+ like so: # # result = Customer.create(:first_name => "John") # if result.success? # # have a SuccessfulResult # puts "Created customer #{result.customer.id} # else # # have an ErrorResult # end class SuccessfulResult include BaseModule def initialize(attributes = {}) # :nodoc: @attrs = attributes.keys singleton_class.class_eval do attributes.each do |key, value| define_method key do value end end end end def inspect # :nodoc: inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } "#<#{self.class} #{inspected_attributes}>" end # Always returns true. def success? true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
braintree-1.1.0 | lib/braintree/successful_result.rb |