lib/aws/core/data.rb in aws-sdk-1.7.1 vs lib/aws/core/data.rb in aws-sdk-1.8.0

- old
+ new

@@ -11,11 +11,11 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. module AWS module Core - + # Data is a light wrapper around a Ruby hash that provides # method missing access to the hash contents. # # == Method Missing Access # @@ -64,11 +64,11 @@ module MethodMissingProxy # @private def id - self[:id] || self.id + self[:id] || self.id end def [] index_or_key Data.cast(@data[index_or_key]) end @@ -82,10 +82,15 @@ @data == other end end alias_method :==, :eql? + def dup + Data.cast(@data.dup) + end + alias_method :clone, :dup + protected def method_missing *args, &block if block_given? return_value = @data.send(*args) do |*values| @@ -104,21 +109,21 @@ end include MethodMissingProxy def method_missing method_name, *args, &block - if + if args.empty? and !block_given? and key = _remove_question_mark(method_name) and @data.has_key?(key) then Data.cast(@data[key]) else super end end - + # @param [Hash] data The ruby hash of data you need wrapped. def initialize data @data = data end @@ -172,18 +177,18 @@ else method_name end end class << self - + # Given a hash, this method returns a {Data} object. Given # an Array, this method returns a {Data::List} object. Everything # else is returned as is. # # @param [Object] value The value to conditionally wrap. # - # @return [Data,Data::List,Object] Wraps hashes and lists with + # @return [Data,Data::List,Object] Wraps hashes and lists with # Data and List objects, all other objects are returned as # is. # def cast value case value @@ -196,11 +201,11 @@ end class List include MethodMissingProxy - + # @param [Array] array def initialize array @data = array end @@ -215,10 +220,10 @@ def to_ary @data end alias_method :to_a, :to_ary - # #inject works on Core::Data::List in in 1.8.7 and 1.9.3, but not + # #inject works on Core::Data::List in in 1.8.7 and 1.9.3, but not # in 1.9.2 unless we define it like so. # @private def inject *args, &block @data.inject(*args) do |obj,value| yield(Data.cast(obj),Data.cast(value))