Sha256: 60df682814f24cf5647b87e4c8106c0d289456f1d8371eff8e60b235943195f6

Contents?: true

Size: 597 Bytes

Versions: 4

Compression:

Stored size: 597 Bytes

Contents

# encoding: utf-8

module Uncharted

  class Country

    class Field
      include Mongoid::Fields::Serializable if defined? Mongoid

      def deserialize(alpha2)
        alpha2 && Uncharted::Country.find(alpha2)
      end

      def serialize(country)
        country && country.alpha2
      end
    end
  end

  class Territory

    class Field
      include Mongoid::Fields::Serializable if defined? Mongoid

      def deserialize(code)
        code && Uncharted::Territory.find(code)
      end

      def serialize(territory)
        territory && territory.code
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
uncharted-0.0.8 lib/uncharted/extensions/mongoid.rb
uncharted-0.0.7.beta1 lib/uncharted/extensions/mongoid.rb
uncharted-0.0.6 lib/uncharted/adapters/mongoid.rb
uncharted-0.0.5 lib/uncharted/adapters/mongoid.rb