Sha256: 3faa0f5fad508937abde68d7093e1ebe79bcb5843db92681dd5b4656aab6f329

Contents?: true

Size: 530 Bytes

Versions: 4

Compression:

Stored size: 530 Bytes

Contents

require 'ostruct'

class Embedly::EmbedlyObject < OpenStruct

  # Resursively make ostruct
  def initialize obj
    o = obj.clone
    o.each do |k,v|
      if v.is_a?Hash
        o[k] = Embedly::EmbedlyObject.new v
      end
    end
    super o
  end

  # for ruby 1.8.x, type should return @table[:type], not the
  # class.
  def type
    method_missing :type
  end

  def marshal_dump
    o = @table.clone
    o.each do |k,v|
      if v.is_a?EmbedlyObject
        o[k] = v.marshal_dump
      end
    end
    return o
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
embedly-0.3.2 lib/embedly/model.rb
embedly-0.3.1 lib/embedly/model.rb
embedly-0.3.0 lib/embedly/model.rb
embedly-0.2.0 lib/embedly/model.rb