Sha256: 143b84fb54f3087bdb821189c7be06a0e6f46cbdbb9c6afbf5a1a8ad3aece74a

Contents?: true

Size: 282 Bytes

Versions: 17

Compression:

Stored size: 282 Bytes

Contents

require 'ostruct'

class OpenStruct
  def self.to_mongo(value)
    if value.kind_of?(self)
      value.send(:table)
    else
      value
    end
  end

  def self.from_mongo(value)
    if value.kind_of?(self)
      value
    else
      OpenStruct.new(value || {})
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mongomapper_ext-0.5.2 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.5.1 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.5.0 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.4.0 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.3.0 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.2.4 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.2.3 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.2.2 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.2.1 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.2.0 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.1.5 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.1.4 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.1.3 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.1.2 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.1.1 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.1.0 lib/mongomapper_ext/types/open_struct.rb
mongomapper_ext-0.0.4 lib/mongomapper_ext/types/open_struct.rb